Hi,
in the child (sale.order.line) class I have a boolean field which should be updated when parent field is changed.
Parent:
class SaleOrder(models.Model):
_inherit = "sale.order"
sub = fields.Many2One(...)
Child:
class SaleOrderLine(models.Model):
_inherit = "sale.order.line"
b = fields.Boolean(compute="_check_sub", default=False)
@api.depends("order_id.sub")
def _check_sub(self):
for rec in self:
if(rec.order_id.sub != False):
rec.b = True
_check_sub is never called. What is the right way to update a child field depending on a parent field?
Thanks!
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Accounting
- Inventory
- PoS
- Project management
- MRP
This question has been flagged
2
Replies
5627
Views
One way is to have a sub field also in order.line and have it related to the sale.order sub field and replace your function with on change so...
class SaleOrderLine(models.Model):
...
sub = fields.Many2one(..., related='order_id.sub', store=False)
@api.multi
@api.onchange('sub')
def _check_sub(self):
...
Thanks for your reply!
The onchange-method "_check_sub()" is not called.. It is the same problem as before..
I change a parent field and the child-methods are not invoked.
Enjoying the discussion? Don't just read, join in!
Create an account today to enjoy exclusive features and engage with our awesome community!
Sign up
I resolved this by adding an onchange-method in the parent model and change the child field in there.