In the form view, I wanted to automatically update the list_price(Product Price)when the standard_price(Cost) and the margin(Desired Profit Margin) are given.
The computed field(list_price) does not change automatically after clicking on the "save manually button"(cloud icon). The change only occurs after refreshing the browser page.
class Phone(models.Model):
_inherit = "product.template"
margin = fields.Float(string="Desired Profit Margin(%)")
list_price = fields.Float(compute="_compute_list_price")
def _compute_list_price(self):
for record in self:
if record.margin:
record.list_price = record.standard_price * (1 + record.margin / 100)
else:
record.list_price = ""
Thanks a lot for your suggestions.