Odoo computed field not updating when dependent field changes

2 weeks ago 17
ARTICLE AD BOX

I created a computed field in my custom module:

from odoo import models, fields, api class SaleOrder(models.Model): _inherit = 'sale.order' total_discount = fields.Float(compute='_compute_total_discount') @api.depends('order_line.discount', 'order_line.price_total') def _compute_total_discount(self): for order in self: order.total_discount = sum(line.discount for line in order.order_line)

But when I update discounts on order lines, total_discount does not change automatically.Do I need to set something else for @api.depends() or update the view?

Read Entire Article