我创建了一个继承模块stock.inventory的模块,我希望按钮"1st validate"仅在"real quantity"与"theoretical quantity"不同时出现 . 这是接口:enter image description here
这是我的xml代码:
<record id="linh_view_inventory_form_ext" model="ir.ui.view">
<field name="name">linh.view.inventory.form.ext</field>
<field name="model">stock.inventory</field>
<field name="inherit_id" ref="stock_account.view_inventory_form_inherit"/>
<field name="form">form</field>
<field name="arch" type="xml">
<button name="action_cancel_inventory" states="confirm" string="Cancel Inventory" type="object" position="before">
<button name="inventory_1st_validate" states="need_validate" string="1st Validate" class="oe_highlight" type="object" attrs="{'invisible':[('theoretical_qty','=','product_qty')]}/>
</button>
<field name="state" position="replace">
<field name="state" widget="statusbar" statusbar_visible="draft,confirm,acct_validated,done"/>
</field>
</field>
</record>
但我得到了这个错误:
错误:域[[“ideal_qty”,“=”,“product_qty”],[“州”,“不在”,[“need_validate”]]]中的未知字段ideal_qty
“theoretical_qty”是我从模型“stock.picking”得到的“理论数量”的字段名称 . 我不知道为什么视图不承认它 .
非常感谢您的帮助 .
1 回答
theoretical_qty
是 stock.inventory.line 的字段,你不能直接在 stock.inventory 里面使用 .您只能在stock.inventory.line的树/窗体视图中使用它 .
还有一件事,对于在attrs内使用一个字段,它也会出现在视图中 .
(在当前视图或继承的父视图中) .