diff options
| author | Miqdad <ahmadmiqdad27@gmail.com> | 2025-09-15 10:12:37 +0700 |
|---|---|---|
| committer | Miqdad <ahmadmiqdad27@gmail.com> | 2025-09-15 10:12:37 +0700 |
| commit | 3bc157731d03e9beb41dab993461b2bd6dcb1953 (patch) | |
| tree | 908b13918028cbec05fb122f5cc677edcd8f0289 | |
| parent | 064cdf03526540e0cde6b6740fc97764c003adff (diff) | |
<Miqdad> balikin
| -rw-r--r-- | indoteknik_custom/models/manufacturing.py | 32 |
1 files 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() |
