简体   繁体   中英

Get field from module then put it to another modul (custom module) odoo 10

I'm wasting time to find out how to getting field from Bill of Materials (BOM) in Manufacturing module odoo for use it on Product categories form in odoo's Inventory module.

here is the detail

想得到这个领域

look at the Components page in Bill of Materials Form I want to make detail form like that (same with that) in product category form using custom module (addons)

then show it on this form 在这里我想把表格放在物料清单上

so product category form will be like this 在此处输入图片说明

I've tried with this code

.py

 from odoo import api, fields, models, _

class CategoryBom(models.Model):
    _name = 'category_bom.sub_bom'
    _inherit = "mrp.bom"

    bom_line_ids = fields.One2many('mrp.bom.line', 'bom_id', 'BoM Lines', copy=True)

.xml

<odoo>
    <data>
        <!-- Add BoM input in category form -->
            <record id="bom_form_in_category_form" model="ir.ui.view">
                <field name="name">mrp.bom.form.inherit_category</field>
                <field name="model">category_bom.sub_bom</field>
                <field name="inherit_id" ref="product.product_category_form_view"></field>
                <field name="type">form</field>
                <field name="arch" type="xml">
                    <group name="first" position="after">
                        <group string="Bill Of Materials">
                            <form string="Bill of Material">
                                <notebook>
                                    <page string="Components">
                                        <field name="bom_line_ids" widget="one2many_list">
                                            <tree string="Components" editable="bottom">
                                                <field name="sequence" widget="handle"/>
                                                <field name="product_id" context="{'default_type': 'product'}"/>
                                                <field name="has_attachments" invisible="1"/>
                                                <button name="action_see_attachments" type="object" icon="fa-files-o" attrs="{'invisible': [('has_attachments', '=', False)]}"/>
                                                <button name="action_see_attachments" type="object" icon="fa-file" attrs="{'invisible': [('has_attachments', '=', True)]}"/>
                                                <field name="product_qty"/>
                                                <field name="product_uom_id" options="{'no_open':True,'no_create':True}" groups="product.group_uom"/>
                                                <field name="attribute_value_ids" widget="many2many_tags" domain="[('product_ids.product_tmpl_id', '=', parent.product_tmpl_id)]" groups="product.group_product_variant"/>
                                                <field name="operation_id" groups="mrp.group_mrp_routings" domain="[('routing_id', '=', parent.routing_id)]" options="{'no_quick_create':True,'no_create_edit':True}"/>
                                            </tree>
                                        </field>
                                    </page>
                                    <page string="Miscellaneous">
                                        <group>
                                            <group>
                                                <field name="sequence"/>
                                            </group>
                                            <group>
                                                <field name="ready_to_produce" string="Manufacturing Readiness"/>
                                                <field name="picking_type_id" string="Operation"/>
                                            </group>
                                        </group>
                                    </page>
                            </notebook>
                            </form>
                        </group>
                    </group>
                </field>
            </record>
    </data>
</odoo>

but when I install the custom module, im getting error

这是一个错误

Thanks in advance, I would be appreciated for your response.

Regards, Odoo Beginner

***FYI : I'm using odoo v.10

in the fourth line, change "type" by "view_type"

it can resolve the problem.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM