How to update the value of field of from view when update the field of tree view?
I want to change the value of "total_location_qty" when I update the value of "location_qty".
This is my 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
This is my view
<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>
Hi did you try the answer?