From c48a2248a874277b7795d86c6247f51430c0b810 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Tue, 20 Jan 2026 15:57:31 +0700 Subject: push --- fixco_custom/models/sale.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'fixco_custom/models/sale.py') diff --git a/fixco_custom/models/sale.py b/fixco_custom/models/sale.py index b8aa963..b880113 100755 --- a/fixco_custom/models/sale.py +++ b/fixco_custom/models/sale.py @@ -21,6 +21,31 @@ class SaleOrder(models.Model): deadline_date = fields.Datetime('Deadline', copy=False) + total_discount = fields.Monetary( + string='Total Discount', + compute='_compute_total_discount', + currency_field='currency_id', + ) + + @api.depends( + 'order_line.price_unit', + 'order_line.product_uom_qty', + 'order_line.discount', + ) + def _compute_total_discount(self): + for order in self: + total = 0.0 + for line in order.order_line: + if line.discount: + line_discount = ( + line.price_unit + * line.product_uom_qty + * line.discount / 100 + ) + total += line_discount + order.total_discount = total + + def create_invoices(self): created_invoices = self.env['account.move'] for order in self: -- cgit v1.2.3