从模块获取字段然后将其放到另一个模块(自定义模块)odoo 10

时间:2017-09-15 06:45:47

标签: python openerp odoo-8 odoo-9 odoo-10

我在浪费时间了解如何从制造模块odoo中的物料清单(BOM)获取字段,以便在odoo的库存模块中的产品类别表单中使用它。

这里是细节

Wanna get this field

查看物料清单表单中的“组件”页面 我想使用自定义模块(插件)

在产品类别表单中制作与此类似的详细信息表单(与之相同)

然后在此表单上显示 here i want to put the form on Bill of Materials

因此产品类别表格将是这样的 enter image description here

我尝试过这段代码

的.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>

但是当我安装自定义模块时,我得到了错误

this in an error

在此先感谢您的回复,我将不胜感激。

此致 Odoo初学者

*** FYI:我正在使用odoo v.10

1 个答案:

答案 0 :(得分:0)

在第四行, 通过“view_type”更改“type”

它可以解决问题。