Hey Cyllo users, what's the best way to automatically update fields based on changes in other fields? Any tips or tricks?
Welcome!
Share and discuss the best content and new marketing ideas, build your professional profile and become a better marketer together.
This question has been flagged
Here's how you can achieve that using the '@api.onchange' decorator. Onchange fields dynamically update values in the form view when a specified field changes, without needing to save the record. These changes affect the user interface but are not persisted to the database until the record is saved. class SaleOrderLine(models.Model): _inherit = 'sale.order.line' discount_reason = fields.Char(string='Discount Reason') @api.onchange('discount') def _onchange_discount(self): if self.discount > 20: self.discount_reason = "High discount – approval required" else: self.discount_reason = ""