diff options
| author | FIN-IT_AndriFP <it@fixcomart.co.id> | 2025-10-17 15:45:48 +0700 |
|---|---|---|
| committer | FIN-IT_AndriFP <it@fixcomart.co.id> | 2025-10-17 15:45:48 +0700 |
| commit | 2cd0d5ede34e2c46b3bcd1f1907cd0526ef42b9d (patch) | |
| tree | 0e3d022b848cb74348521de05a632de1f66f1341 | |
| parent | 66983246c83db072c62abba4a40a70e514b081d0 (diff) | |
(andri) butuh approval pimpinan bila ada perubahan unit price pada PO PJ + matches SO margin header <=15%
| -rwxr-xr-x | indoteknik_custom/models/purchase_order.py | 6 | ||||
| -rwxr-xr-x | indoteknik_custom/models/purchase_order_line.py | 6 | ||||
| -rwxr-xr-x | indoteknik_custom/views/purchase_order.xml | 1 |
3 files changed, 11 insertions, 2 deletions
diff --git a/indoteknik_custom/models/purchase_order.py b/indoteknik_custom/models/purchase_order.py index 701c0a3f..51517437 100755 --- a/indoteknik_custom/models/purchase_order.py +++ b/indoteknik_custom/models/purchase_order.py @@ -1074,8 +1074,10 @@ class PurchaseOrder(models.Model): 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.") + 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%") # 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_line.py b/indoteknik_custom/models/purchase_order_line.py index a3c3a33b..8c72887d 100755 --- a/indoteknik_custom/models/purchase_order_line.py +++ b/indoteknik_custom/models/purchase_order_line.py @@ -51,6 +51,12 @@ class PurchaseOrderLine(models.Model): contribution_cost_service = fields.Float(string='Contribution Cost Service', compute='_compute_doc_delivery_amt') ending_price = fields.Float(string='Ending Price', compute='_compute_doc_delivery_amt') show_description = fields.Boolean(string='Show Description', help="Show Description when print po", default=True) + price_unit_before = fields.Float(string='Unit Price Before', help="Harga awal yang sebelumnya telah diinputkan") + + @api.onchange('price_unit') + def _onchange_price_unit_before(self): + if self._origin: + self.price_unit_before = self._origin.price_unit def _compute_doc_delivery_amt(self): for line in self: diff --git a/indoteknik_custom/views/purchase_order.xml b/indoteknik_custom/views/purchase_order.xml index 437b86b8..09d901b9 100755 --- a/indoteknik_custom/views/purchase_order.xml +++ b/indoteknik_custom/views/purchase_order.xml @@ -144,6 +144,7 @@ <field name="cost_service_per_item" optional="hide"/> <field name="contribution_cost_service" optional="hide"/> <field name="ending_price" optional="hide"/> + <field name="price_unit_before" readonly="1" optional="hide" force_save="1"/> <!-- <field name="suggest" readonly="1"/> --> </field> <field name="product_id" position="before"> |
