0
我需要在Odoo 10中扩展一个表单(stock.view_inventory_form)。表单中有一个子树填充了来自另一个模型的相关记录。下面是我想改变原始形式的一部分:odoo 10:扩展相关记录的视图树(inventory.stock.line)
<field name="line_ids" string="Inventory Details" context="{'default_location_id': location_id, 'default_product_id': product_id, 'default_prod_lot_id': lot_id, 'default_package_id': package_id, 'default_partner_id': partner_id}" mode="tree,kanban">
<tree string="Inventory Details" editable="bottom" decoration-info="product_qty != theoretical_qty" decoration-danger="theoretical_qty < 0">
<field name="product_id" domain="[('type','=','product')]"/>
<field name="product_uom_id" string="UoM" groups="product.group_uom"/>
<field name="location_id" domain="[('id', 'child_of', parent.location_id)]" groups="stock.group_stock_multi_locations"/>
<field name="prod_lot_id" domain="[('product_id', '=', product_id)]" context="{'default_product_id': product_id}" groups="stock.group_production_lot"/>
<field name="package_id" domain="['|', ('location_id','=', False), ('location_id', '=', location_id)]" groups="stock.group_tracking_lot"/>
<field name="partner_id" groups="stock.group_tracking_owner"/>
<field name="theoretical_qty" readonly="1"/>
<field name="product_qty" string="Real Quantity"/>
<field name="state" invisible="True"/>
</tree>
</field>
哪里line_ids是从相关模型(stock.inventory.line)的字段。所以我扩展了以下的模式:
class stock_inventory_line(models.Model):
_inherit = 'stock.inventory.line'
x_container_details = fields.Char('Container details')
x_wagon_no = fields.Char('Wagon No')
x_seal_no = fields.Char('Seal No')
x_invoice_no = fields.Integer('Invoice No')
x_net_weight = fields.Integer('Net weight')
x_gross_weight = fields.Integer('Gross Weight')
然后我试着用下面的代码扩展形式:
<record id="view_form_todo_task_inherited" model="ir.ui.view">
<field name="name">Test</field>
<field name="model">stock.inventory</field>
<field name="inherit_id" ref="stock.view_inventory_form"/>
<field name="arch" type="xml">
<field name="line_ids">
<field name="x_container_details"/>
<field name="x_wagon_no"/>
</field>
</field>
</record>
Odoo没有返回任何错误,但我的字段是不是在显示(子)树的形式..我做错了什么? 感谢任何人都可以提供帮助!
谢谢胡安萨尔塞多!有用。 我以前在我的示例中没有使用xpath的方式扩展了非相关字段,所以我认为有一种方法可以在不使用xpath的情况下执行。 – GiulioG
我很高兴听到这个消息,是的,你不能使用'xpath',但你也应该指出位置,>,但我认为使用'xpath'更有用直观地使用比“领域”,并为您的情况下,如果有更多的'状态'定义,你可以麻烦找到你想使用的字段(状态),这就是为什么我指定'/ /树/字段'路径。 –