0
如何在更新树视图的字段时更新来自视图的字段的值?如何在更新树视图的字段时更新查看字段的值?
我想在更新“location_qty”的值时更改“total_location_qty”的值。
这是我的OBJ
class Demo(models.TransientModel):
_name = 'demo.parent'
demo_lines_ids = fields.One2many('demo.lines', 'demo_id', 'demo Items')
total_location_qty = fields.Float(string='Total of location qty')
class DemoLines(models.TransientModel):
_name = "demo.lines"
demo_id = fields.Many2one('demo.parent', 'Demo')
location_id = fields.Many2one('stock.location', 'Stock Location', readonly=True)
location_qty = fields.Float(string='Location Qty')
@api.onchange('location_qty')
def on_change_location_qty(self):
self.demo_id.total_location_qty = self.location_qty
这是我的看法
<record id="view_demo_wizard" model="ir.ui.view">
<field name="name">Demo</field>
<field name="model">demo.parent</field>
<field name="arch" type="xml">
<form string="Demo Parent">
<group string="Demo">
<group colspan="4">
<field name="total_location_qty" readonly="1"/>
</group>
<field name="demo_lines_ids" nolabel="1" >
<tree string="Demo Lines" editable="bottom" create="false" delete="false" >
<field name="location_qty"/>
</tree>
</field>
</group>
</form>
</field>
</record>
尝试使用'@ api.one'装饰器以及两者同时 – ChesuCR