summaryrefslogtreecommitdiff
path: root/indoteknik_custom/models/purchase_order.py
diff options
context:
space:
mode:
authorFIN-IT_AndriFP <andrifebriyadiputra@gmail.com>2026-01-09 14:43:31 +0700
committerFIN-IT_AndriFP <andrifebriyadiputra@gmail.com>2026-01-09 14:43:31 +0700
commite8291422441d48909252471282c4b72372cccefb (patch)
tree60e1e280dc5bfc8d670523b04ff4582a8a35e9bb /indoteknik_custom/models/purchase_order.py
parentff058e22f64cd3e2dbd69d835f68877f530820c3 (diff)
parentae961c97d736359f6611db82ee484707f581ab0f (diff)
Merge branch 'odoo-backup' of https://bitbucket.org/altafixco/indoteknik-addons into magento-solr-v1
Diffstat (limited to 'indoteknik_custom/models/purchase_order.py')
-rwxr-xr-xindoteknik_custom/models/purchase_order.py15
1 files changed, 9 insertions, 6 deletions
diff --git a/indoteknik_custom/models/purchase_order.py b/indoteknik_custom/models/purchase_order.py
index 3d22b0f0..a114743f 100755
--- a/indoteknik_custom/models/purchase_order.py
+++ b/indoteknik_custom/models/purchase_order.py
@@ -1081,13 +1081,16 @@ class PurchaseOrder(models.Model):
def button_confirm(self):
if self.env.user.id != 7 and not self.env.user.is_leader: # Pimpinan
if '/PJ/' in self.name:
- low_margin_lines = self.order_sales_match_line.filtered(
- lambda match: match.so_header_margin <= 15.0
- )
price_change_detected = any(line.price_unit_before for line in self.order_line)
- if low_margin_lines and price_change_detected:
- # raise UserError("Matches SO terdapat item dengan header margin SO <= 15%. Approval Pimpinan diperlukan.")
- raise UserError("Approval Pimpinan diperlukan jika terdapat perubahan Unit Price pada PO Line yang Matches SO item memiliki header margin SO <= 15%")
+ if price_change_detected:
+ if self.total_percent_margin <= 15.0:
+ raise UserError("Approval Pimpinan diperlukan jika terdapat perubahan Unit Price pada PO Line dan Memiliki Margin <= 15%")
+ else:
+ low_margin_match_so = self.order_sales_match_line.filtered(
+ lambda match: match.so_header_margin <= 15.0
+ )
+ if low_margin_match_so:
+ raise UserError("Approval Pimpinan diperlukan jika pada PO Line yang Matches SO item memiliki header margin SO <= 15%")
# else:
# is_po_manual = '/A/' not in self.name and '/MO/' not in self.name
# if is_po_manual: