diff options
Diffstat (limited to 'fixco_custom/models/sale.py')
| -rwxr-xr-x | fixco_custom/models/sale.py | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/fixco_custom/models/sale.py b/fixco_custom/models/sale.py index 90cc581..ab03acd 100755 --- a/fixco_custom/models/sale.py +++ b/fixco_custom/models/sale.py @@ -1,5 +1,8 @@ from odoo import api, fields, models, _ from odoo.exceptions import UserError +import logging + +_logger = logging.getLogger(__name__) class SaleOrder(models.Model): @@ -28,6 +31,31 @@ class SaleOrder(models.Model): ) uangmuka_exist = fields.Boolean(string='Uang Muka Exist', copy=False) + delivery_amount = fields.Monetary("Delivery Amount", currency_field='currency_id') + + marketplace_discount = fields.Monetary( + string="Marketplace Discount", + currency_field='currency_id' + ) + + marketplace_tax = fields.Monetary( + string="Marketplace Tax", + currency_field='currency_id' + ) + + @api.depends('order_line.price_total', 'delivery_amount') + def _amount_all(self): + super()._amount_all() + + for order in self: + if order.partner_id.id == 281: + subtotal = sum(line.price_subtotal for line in order.order_line) + tax = order.marketplace_tax + delivery = order.delivery_amount or 0 + discount = order.marketplace_discount or 0 + + order.amount_total = subtotal + tax + delivery + discount + @api.depends( 'order_line.price_unit', 'order_line.product_uom_qty', @@ -35,6 +63,11 @@ class SaleOrder(models.Model): ) def _compute_total_discount(self): for order in self: + if order.partner_id.id == 281: + # Biar gk error + order.total_discount = order.total_discount + continue + total = 0.0 for line in order.order_line: if line.discount: |
