summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAzka Nathan <darizkyfaz@gmail.com>2025-03-27 09:21:16 +0700
committerAzka Nathan <darizkyfaz@gmail.com>2025-03-27 09:21:16 +0700
commit6a0664215fab4f63928092d98214acb7b68fdff5 (patch)
treea22dbbc3b58f8a95e010df83c3ebf7da4b430feb
parent321b0c365c722c4a357d7da17cd25561f1d5f78d (diff)
fix bug so
-rwxr-xr-xindoteknik_custom/models/sale_order.py14
1 files changed, 10 insertions, 4 deletions
diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py
index bee7d6a7..89ed0327 100755
--- a/indoteknik_custom/models/sale_order.py
+++ b/indoteknik_custom/models/sale_order.py
@@ -239,8 +239,14 @@ class SaleOrder(models.Model):
@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
+ if rec.fee_third_party == 0 and rec.total_margin_excl_third_party != rec.total_percent_margin:
+ # Gunakan direct SQL atau flag context untuk menghindari rekursi
+ self.env.cr.execute("""
+ UPDATE sale_order
+ SET total_margin_excl_third_party = %s
+ WHERE id = %s
+ """, (rec.total_percent_margin, rec.id))
+ self.invalidate_cache()
@api.constrains('shipping_option_id')
def _check_shipping_option(self):
@@ -1692,7 +1698,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._check_total_margin_excl_third_party()
# order._update_partner_details()
return order
@@ -1736,7 +1742,7 @@ class SaleOrder(models.Model):
res = super(SaleOrder, self).write(vals)
self._validate_delivery_amt()
- self._check_total_margin_excl_third_party()
+ # 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: