Hi everyone,
I’m facing an issue with multiple @api.onchange methods where one onchange indirectly triggers another due to a field update inside it. This leads to unexpected behavior in domain filtering.
Let’s say I have two onchange methods:
@api.onchange('field_a') def onchange_a(self): self.domain_field = some_logic_based_on_a @api.onchange('field_b') def onchange_b(self): self.field_a = False # This triggers onchange_a again self.domain_field = some_logic_based_on_b
The problem is that when field_b changes, it updates field_a, which re-triggers onchange_a, and this overwrites the domain logic set by onchange_b.
As a result, the final domain on domain_field becomes inconsistent or incorrect, depending on which onchange executes last.
In complex forms where multiple fields influence a shared domain or selection field, this kind of chained onchange can cause:
- Unintended overrides of previous logic.
- Incorrect domain being applied.
- Confusing user experience on the form.
What’s the best way to handle such cases in Odoo?
- Is there a way to control or prevent re-triggering another onchange when setting a field inside one?
-
Any alternative way to achieve that things
- Any better practice to manage interdependent fields without causing these side-effects?
Thanks in advance for any advice!