From 6adb1cb5fe8dbe85b971dc1cad476718f24c38cb Mon Sep 17 00:00:00 2001 From: FIN-IT_AndriFP Date: Wed, 1 Oct 2025 13:49:26 +0700 Subject: (andri) add validasi approval pimpinan jika PO biasa tidak ada matches SO dan PO PJ terdapat matches SO line dengan SO margin <=15% --- indoteknik_custom/models/purchase_order.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) 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() -- cgit v1.2.3 From c04dd5a6a38ba35b30a39ed6596514679067e541 Mon Sep 17 00:00:00 2001 From: FIN-IT_AndriFP Date: Wed, 1 Oct 2025 15:10:10 +0700 Subject: (andri) add so header margin pada matches SO + fix --- indoteknik_custom/models/purchase_order.py | 4 ++-- indoteknik_custom/models/purchase_order_sales_match.py | 5 +++++ indoteknik_custom/views/purchase_order.xml | 1 + 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/indoteknik_custom/models/purchase_order.py b/indoteknik_custom/models/purchase_order.py index a76cdab1..1a88d036 100755 --- a/indoteknik_custom/models/purchase_order.py +++ b/indoteknik_custom/models/purchase_order.py @@ -1072,10 +1072,10 @@ class PurchaseOrder(models.Model): 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 + lambda match: match.so_header_margin <= 34.0 ) if low_margin_lines: - raise UserError("Matches SO terdapat item dengan margin SO <= 15%. Approval Pimpinan diperlukan.") + raise UserError("Matches SO terdapat item dengan header 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: diff --git a/indoteknik_custom/models/purchase_order_sales_match.py b/indoteknik_custom/models/purchase_order_sales_match.py index 084b93f7..ea25a3b1 100644 --- a/indoteknik_custom/models/purchase_order_sales_match.py +++ b/indoteknik_custom/models/purchase_order_sales_match.py @@ -29,6 +29,11 @@ class PurchaseOrderSalesMatch(models.Model): purchase_line_id = fields.Many2one('purchase.order.line', string='Purchase Line', compute='_compute_purchase_line_id') hold_outgoing_so = fields.Boolean(string='Hold Outgoing SO', related='sale_id.hold_outgoing') bu_pick = fields.Many2one('stock.picking', string='BU Pick', compute='compute_bu_pick') + so_header_margin = fields.Float( + related='sale_id.total_percent_margin', + string='SO Header Margin %', + readonly=True + ) def compute_bu_pick(self): for rec in self: diff --git a/indoteknik_custom/views/purchase_order.xml b/indoteknik_custom/views/purchase_order.xml index 7feec934..437b86b8 100755 --- a/indoteknik_custom/views/purchase_order.xml +++ b/indoteknik_custom/views/purchase_order.xml @@ -390,6 +390,7 @@ + -- cgit v1.2.3 From 8ff0270ee40b34d8eb85cd8d5e9572211a0e36a9 Mon Sep 17 00:00:00 2001 From: FIN-IT_AndriFP Date: Thu, 16 Oct 2025 11:52:52 +0700 Subject: (andri) off check po manual confirm --- indoteknik_custom/models/purchase_order.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/indoteknik_custom/models/purchase_order.py b/indoteknik_custom/models/purchase_order.py index 1a88d036..f8718a0d 100755 --- a/indoteknik_custom/models/purchase_order.py +++ b/indoteknik_custom/models/purchase_order.py @@ -1072,15 +1072,15 @@ class PurchaseOrder(models.Model): if self.env.user.id != 7: # Pimpinan if '/PJ/' in self.name: low_margin_lines = self.order_sales_match_line.filtered( - lambda match: match.so_header_margin <= 34.0 + lambda match: match.so_header_margin <= 15.0 ) if low_margin_lines: raise UserError("Matches SO terdapat item dengan header 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.") + # 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 -- cgit v1.2.3 From e210b6fa5ec6603920f550e5f8cc64e32e832e44 Mon Sep 17 00:00:00 2001 From: FIN-IT_AndriFP Date: Thu, 16 Oct 2025 12:01:20 +0700 Subject: (andri) fix --- indoteknik_custom/models/purchase_order.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indoteknik_custom/models/purchase_order.py b/indoteknik_custom/models/purchase_order.py index f8718a0d..7badff95 100755 --- a/indoteknik_custom/models/purchase_order.py +++ b/indoteknik_custom/models/purchase_order.py @@ -1069,7 +1069,7 @@ class PurchaseOrder(models.Model): ) % order.name) def button_confirm(self): - if self.env.user.id != 7: # Pimpinan + 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 -- cgit v1.2.3