From 064cdf03526540e0cde6b6740fc97764c003adff Mon Sep 17 00:00:00 2001 From: Miqdad Date: Sun, 14 Sep 2025 00:42:04 +0700 Subject: MO kalau sudah jadi PO tidak perlu approval purchasing manager --- indoteknik_custom/models/manufacturing.py | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/indoteknik_custom/models/manufacturing.py b/indoteknik_custom/models/manufacturing.py index aea01362..3e4f386d 100644 --- a/indoteknik_custom/models/manufacturing.py +++ b/indoteknik_custom/models/manufacturing.py @@ -7,22 +7,24 @@ _logger = logging.getLogger(__name__) class Manufacturing(models.Model): _inherit = 'mrp.production' unbuild_counter = fields.Integer(string='Unbuild Counter', default=0, help='For restrict unbuild more than once') - + def action_confirm(self): if self._name != 'mrp.production': return super(Manufacturing, self).action_confirm() - if not self.env.user.is_purchasing_manager: - raise UserError("Hanya bisa di confirm oleh Purchasing Manager") - - # if self.location_src_id.id != 75: - # raise UserError('Component Location hanya bisa di AS/Stock') - # elif self.location_dest_id.id != 75: - # raise UserError('Finished Product Location hanya bisa di AS/Stock') - - result = super(Manufacturing, self).action_confirm() - return result - + for mo in self: + has_po_flag = bool(getattr(mo, 'is_po', False)) + has_po_link = bool(self.env['purchase.order'].search([ + ('manufacturing_id', '=', mo.id), + ('state', '!=', 'cancel') + ], limit=1)) + mo_has_po = has_po_flag or has_po_link + + if not mo_has_po and not self.env.user.is_purchasing_manager: + raise UserError("Hanya bisa di confirm oleh Purchasing Manager") + + return super(Manufacturing, self).action_confirm() + def button_mark_done(self): if self._name != 'mrp.production': return super(Manufacturing, self).button_mark_done() -- cgit v1.2.3 From 3bc157731d03e9beb41dab993461b2bd6dcb1953 Mon Sep 17 00:00:00 2001 From: Miqdad Date: Mon, 15 Sep 2025 10:12:37 +0700 Subject: balikin --- indoteknik_custom/models/manufacturing.py | 32 +++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/indoteknik_custom/models/manufacturing.py b/indoteknik_custom/models/manufacturing.py index 3e4f386d..f986fd4f 100644 --- a/indoteknik_custom/models/manufacturing.py +++ b/indoteknik_custom/models/manufacturing.py @@ -4,6 +4,7 @@ import logging _logger = logging.getLogger(__name__) + class Manufacturing(models.Model): _inherit = 'mrp.production' unbuild_counter = fields.Integer(string='Unbuild Counter', default=0, help='For restrict unbuild more than once') @@ -12,18 +13,16 @@ class Manufacturing(models.Model): if self._name != 'mrp.production': return super(Manufacturing, self).action_confirm() - for mo in self: - has_po_flag = bool(getattr(mo, 'is_po', False)) - has_po_link = bool(self.env['purchase.order'].search([ - ('manufacturing_id', '=', mo.id), - ('state', '!=', 'cancel') - ], limit=1)) - mo_has_po = has_po_flag or has_po_link + if not self.env.user.is_purchasing_manager: + raise UserError("Hanya bisa di confirm oleh Purchasing Manager") - if not mo_has_po and not self.env.user.is_purchasing_manager: - raise UserError("Hanya bisa di confirm oleh Purchasing Manager") + # if self.location_src_id.id != 75: + # raise UserError('Component Location hanya bisa di AS/Stock') + # elif self.location_dest_id.id != 75: + # raise UserError('Finished Product Location hanya bisa di AS/Stock') - return super(Manufacturing, self).action_confirm() + result = super(Manufacturing, self).action_confirm() + return result def button_mark_done(self): if self._name != 'mrp.production': @@ -31,29 +30,30 @@ class Manufacturing(models.Model): # Check product category if self.product_id.categ_id.name != 'Finish Good': raise UserError('Tidak bisa di complete karna product category bukan Unit / Finish Good') - + if self.sale_order and self.sale_order.state != 'sale': raise UserError( ('Tidak bisa Mark as Done.\nSales Order "%s" (Nomor: %s) belum dikonfirmasi.') % (self.sale_order.partner_id.name, self.sale_order.name) ) - + for line in self.move_raw_ids: # if line.quantity_done > 0 and line.quantity_done != self.product_uom_qty: # raise UserError('Qty Consume per Line tidak sama dengan Qty to Produce') if line.forecast_availability != line.product_uom_qty: - raise UserError('Qty Reserved belum sesuai dengan yang seharusnya, product: %s' % line.product_id.display_name) + raise UserError( + 'Qty Reserved belum sesuai dengan yang seharusnya, product: %s' % line.product_id.display_name) result = super(Manufacturing, self).button_mark_done() return result - + def button_unbuild(self): if self._name != 'mrp.production': return super(Manufacturing, self).button_unbuild() - + if self.unbuild_counter >= 1: raise UserError('Tidak bisa unbuild lebih dari 1 kali') - + self.unbuild_counter = self.unbuild_counter + 1 result = super(Manufacturing, self).button_unbuild() -- cgit v1.2.3 From 248c42efcc30cb55d1827bb7b1e438753ffd0898 Mon Sep 17 00:00:00 2001 From: Miqdad Date: Mon, 15 Sep 2025 11:07:40 +0700 Subject: done --- indoteknik_custom/models/purchase_order.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/indoteknik_custom/models/purchase_order.py b/indoteknik_custom/models/purchase_order.py index 18811b85..98cf6ff1 100755 --- a/indoteknik_custom/models/purchase_order.py +++ b/indoteknik_custom/models/purchase_order.py @@ -1066,8 +1066,11 @@ class PurchaseOrder(models.Model): # sticky=True # ) + has_bom = self.product_bom_id.id + has_manufacturing = self.manufacturing_id.id + if not self.from_apo: - if not self.matches_so and not self.env.user.is_purchasing_manager and not self.env.user.is_leader: + if not self.matches_so and not self.env.user.is_purchasing_manager and not self.env.user.is_leader and not has_bom and not has_manufacturing: raise UserError("Tidak ada link dengan SO, harus di confirm oleh Purchasing Manager") send_email = False -- cgit v1.2.3