summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFIN-IT_AndriFP <it@fixcomart.co.id>2025-10-01 13:49:26 +0700
committerFIN-IT_AndriFP <it@fixcomart.co.id>2025-10-01 13:49:26 +0700
commit6adb1cb5fe8dbe85b971dc1cad476718f24c38cb (patch)
tree49e8773aee83acaed3b3dc835efbe244e741875a
parente92f83f5938966aa6b171be3743ea853d1cffdc7 (diff)
(andri) add validasi approval pimpinan jika PO biasa tidak ada matches SO dan PO PJ terdapat matches SO line dengan SO margin <=15%
-rwxr-xr-xindoteknik_custom/models/purchase_order.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/indoteknik_custom/models/purchase_order.py b/indoteknik_custom/models/purchase_order.py
index b34ec926..a76cdab1 100755
--- a/indoteknik_custom/models/purchase_order.py
+++ b/indoteknik_custom/models/purchase_order.py
@@ -1069,6 +1069,19 @@ class PurchaseOrder(models.Model):
) % order.name)
def button_confirm(self):
+ if self.env.user.id != 7: # Pimpinan
+ if '/PJ/' in self.name:
+ low_margin_lines = self.order_sales_match_line.filtered(
+ lambda match: match.sale_line_id.item_percent_margin <= 34.0
+ )
+ if low_margin_lines:
+ raise UserError("Matches SO terdapat item dengan margin SO <= 15%. Approval Pimpinan diperlukan.")
+ else:
+ is_po_manual = '/A/' not in self.name and '/MO/' not in self.name
+ if is_po_manual:
+ if not self.order_sales_match_line:
+ raise UserError("Tidak ada matches SO, Approval Pimpinan diperlukan.")
+
self._check_assets_note()
# self._check_payment_term() # check payment term
res = super(PurchaseOrder, self).button_confirm()