summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIT Fixcomart <it@fixcomart.co.id>2025-10-16 05:02:35 +0000
committerIT Fixcomart <it@fixcomart.co.id>2025-10-16 05:02:35 +0000
commitf32b6681379ae24945eeb238e46886772aa440ec (patch)
tree245c9b471e112ba2811cb4a3d9220dc41e633cb6
parent7abcc2bd055eecea8caacae8187b7dacff671c46 (diff)
parente210b6fa5ec6603920f550e5f8cc64e32e832e44 (diff)
Merged in matches-so-v2 (pull request #450)
Matches so v2
-rwxr-xr-xindoteknik_custom/models/purchase_order.py13
-rw-r--r--indoteknik_custom/models/purchase_order_sales_match.py5
-rwxr-xr-xindoteknik_custom/views/purchase_order.xml1
3 files changed, 19 insertions, 0 deletions
diff --git a/indoteknik_custom/models/purchase_order.py b/indoteknik_custom/models/purchase_order.py
index 672db7cf..b596f365 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 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
+ )
+ 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.")
+
self._check_assets_note()
# self._check_payment_term() # check payment term
res = super(PurchaseOrder, self).button_confirm()
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 @@
<field name="hold_outgoing_so" optional="hide"/>
<field name="bu_pick" optional="hide"/>
<field name="margin_so"/>
+ <field name="so_header_margin" optional="hide"/>
</tree>
</field>
</record>