0

I have a field two float fields I have added to the res.partner model. Now I have another completely different model that uses some parts of res.partner (i.e name, phone) but it doesn't inherit it. So what I would like to do is to update a field in my custom model anytime the two float fields I added in res.partner are updated. I tried using @api.depends but it doesn't seem to work with fields from a different model, although I have read otherwise.

1 Answer 1

0

Try it with api.onchange

partner_id = fields.Many2one('res.partner', 'Partners')

one_float = fields.Float('One Float', related='partner_id.one_field')
two_float = fields.Float('Two Float', related='partner_id.two_field')

@api.onchange('one_float', 'two_float')
def on_change_state(self):
    self.update_field = 'something'
Sign up to request clarification or add additional context in comments.

2 Comments

I think the onchange decorator only works when a field is within a form view of a model. So it can't work in my case where I want like a more dynamic solution.
@ITJ How about @api.depends('one_float', 'two_float')?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.