diff options
| author | Azka Nathan <darizkyfaz@gmail.com> | 2026-01-20 15:57:31 +0700 |
|---|---|---|
| committer | Azka Nathan <darizkyfaz@gmail.com> | 2026-01-20 15:57:31 +0700 |
| commit | c48a2248a874277b7795d86c6247f51430c0b810 (patch) | |
| tree | dfa9540bbc72bcbdbc54844e97c1a47788cbeefb /fixco_custom/models/sale.py | |
| parent | d2268706824167cd23dd3ea9e22acc241bc35122 (diff) | |
push
Diffstat (limited to 'fixco_custom/models/sale.py')
| -rwxr-xr-x | fixco_custom/models/sale.py | 25 |
1 files changed, 25 insertions, 0 deletions
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: |
