diff options
| author | Miqdad <ahmadmiqdad27@gmail.com> | 2025-09-14 00:42:04 +0700 |
|---|---|---|
| committer | Miqdad <ahmadmiqdad27@gmail.com> | 2025-09-14 00:42:04 +0700 |
| commit | 064cdf03526540e0cde6b6740fc97764c003adff (patch) | |
| tree | 9439d764267db1bfa1039129970984aa50b77dfc | |
| parent | b1ed808b9b21187afe89bf5a44ecf635132d51da (diff) | |
<Miqdad> MO kalau sudah jadi PO tidak perlu approval purchasing manager
| -rw-r--r-- | indoteknik_custom/models/manufacturing.py | 26 |
1 files 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() |
