Code: Select all
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)
Mobile version