summaryrefslogtreecommitdiff
path: root/indoteknik_custom/models/sale_order.py
diff options
context:
space:
mode:
authorAzka Nathan <darizkyfaz@gmail.com>2025-03-26 16:39:19 +0700
committerAzka Nathan <darizkyfaz@gmail.com>2025-03-26 16:39:19 +0700
commit03d667e9a6f33531a41000eed335212abe79a5fb (patch)
tree03fa88756422cf8a8d652915fa648690956fad20 /indoteknik_custom/models/sale_order.py
parent20cf871492e9de61669c577d31d2219d092796bf (diff)
parentcefc6ec6de52f2c79c1760cf88db3375f4956a31 (diff)
Merge branch 'cr/manzila-commision' into odoo-backup
# Conflicts: # indoteknik_custom/models/sale_order.py # indoteknik_custom/models/stock_picking.py
Diffstat (limited to 'indoteknik_custom/models/sale_order.py')
-rwxr-xr-xindoteknik_custom/models/sale_order.py16
1 files changed, 14 insertions, 2 deletions
diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py
index 1778536b..bee7d6a7 100755
--- a/indoteknik_custom/models/sale_order.py
+++ b/indoteknik_custom/models/sale_order.py
@@ -73,6 +73,7 @@ class SaleOrder(models.Model):
order_sales_match_line = fields.One2many('sales.order.purchase.match', 'sales_order_id', string='Purchase Match Lines', states={'cancel': [('readonly', True)], 'done': [('readonly', True)]}, copy=True)
total_margin = fields.Float('Total Margin', compute='_compute_total_margin', help="Total Margin in Sales Order Header")
total_percent_margin = fields.Float('Total Percent Margin', compute='_compute_total_percent_margin', help="Total % Margin in Sales Order Header")
+ total_margin_excl_third_party = fields.Float('Before Margin', help="Before Margin in Sales Order Header")
approval_status = fields.Selection([
('pengajuan1', 'Approval Manager'),
('pengajuan2', 'Approval Pimpinan'),
@@ -104,6 +105,7 @@ class SaleOrder(models.Model):
domain="['|', ('company_id', '=', False), ('company_id', '=', company_id)]",
help="Dipakai untuk alamat tempel", tracking=True)
fee_third_party = fields.Float('Fee Pihak Ketiga')
+ biaya_lain_lain = fields.Float('Biaya Lain Lain')
so_status = fields.Selection([
('terproses', 'Terproses'),
('sebagian', 'Sebagian Diproses'),
@@ -234,6 +236,12 @@ class SaleOrder(models.Model):
nomor_so_pengganti = fields.Char(string='Nomor SO Pengganti', copy=False, tracking=3)
shipping_option_id = fields.Many2one("shipping.option", string="Selected Shipping Option", domain="['|', ('sale_order_id', '=', False), ('sale_order_id', '=', id)]")
+ @api.constrains('fee_third_party', 'delivery_amt', 'biaya_lain_lain')
+ def _check_total_margin_excl_third_party(self):
+ for rec in self:
+ if rec.fee_third_party == 0:
+ rec.total_margin_excl_third_party = rec.total_percent_margin
+
@api.constrains('shipping_option_id')
def _check_shipping_option(self):
for rec in self:
@@ -453,7 +461,7 @@ class SaleOrder(models.Model):
delivery_amt = order.delivery_amt
else:
delivery_amt = 0
- order.percent_margin_after_delivery_purchase = round((order.margin_after_delivery_purchase / (order.amount_untaxed-delivery_amt-order.fee_third_party)) * 100, 2)
+ order.percent_margin_after_delivery_purchase = round((order.margin_after_delivery_purchase / (order.amount_untaxed-delivery_amt-order.fee_third_party-order.biaya_lain_lain)) * 100, 2)
def _compute_date_kirim(self):
for rec in self:
@@ -1427,7 +1435,7 @@ class SaleOrder(models.Model):
delivery_amt = 0
# order.total_percent_margin = round((order.total_margin / (order.amount_untaxed-delivery_amt-order.fee_third_party)) * 100, 2)
- order.total_percent_margin = round((order.total_margin / (order.amount_untaxed-order.fee_third_party)) * 100, 2)
+ order.total_percent_margin = round((order.total_margin / (order.amount_untaxed-order.fee_third_party-order.biaya_lain_lain)) * 100, 2)
# order.total_percent_margin = round((order.total_margin / (order.amount_untaxed)) * 100, 2)
@api.onchange('sales_tax_id')
@@ -1684,6 +1692,7 @@ class SaleOrder(models.Model):
order._compute_etrts_date()
order._validate_expected_ready_ship_date()
order._validate_delivery_amt()
+ order._check_total_margin_excl_third_party()
# order._update_partner_details()
return order
@@ -1727,6 +1736,9 @@ class SaleOrder(models.Model):
res = super(SaleOrder, self).write(vals)
self._validate_delivery_amt()
+ self._check_total_margin_excl_third_party()
if any(field in vals for field in ["order_line", "client_order_ref"]):
self._calculate_etrts_date()
+ if 'order_line' in vals:
+ self._compute_etrts_date()
return res \ No newline at end of file