summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortrisusilo48 <tri.susilo@altama.co.id>2025-03-27 09:27:03 +0700
committertrisusilo48 <tri.susilo@altama.co.id>2025-03-27 09:27:03 +0700
commitbcc1778cd95ee7389d3432ac9ab0520668f0f8fd (patch)
treed9bcc772365a32121f2ba8812cfc64ee772a4adf
parentd34d5dfbf8ef449b57bca9031bd5a28a1bf1928d (diff)
parent91e2374469c3def7f980e7a079782cc3e2238424 (diff)
Merge branch 'odoo-backup' of https://bitbucket.org/altafixco/indoteknik-addons into odoo-backup
-rwxr-xr-xindoteknik_custom/models/sale_order.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py
index 993eaed1..6dd31d89 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):