diff options
| author | FIN-IT_AndriFP <it@fixcomart.co.id> | 2025-10-15 15:13:19 +0700 |
|---|---|---|
| committer | FIN-IT_AndriFP <it@fixcomart.co.id> | 2025-10-15 15:13:19 +0700 |
| commit | 787ce986cc652bd92d0e477c11853eaef871b4e5 (patch) | |
| tree | 5b9df5e357e301d84554618e3592bdfd389c8178 /indoteknik_custom/models/mrp_production.py | |
| parent | c04dd5a6a38ba35b30a39ed6596514679067e541 (diff) | |
| parent | ee6d5d4433a397ca5cdf3474f29bcbd0b2553736 (diff) | |
Merge branch 'odoo-backup' of https://bitbucket.org/altafixco/indoteknik-addons into matches-so-v2
Diffstat (limited to 'indoteknik_custom/models/mrp_production.py')
| -rw-r--r-- | indoteknik_custom/models/mrp_production.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/indoteknik_custom/models/mrp_production.py b/indoteknik_custom/models/mrp_production.py index b39995b5..30956082 100644 --- a/indoteknik_custom/models/mrp_production.py +++ b/indoteknik_custom/models/mrp_production.py @@ -21,6 +21,22 @@ class MrpProduction(models.Model): ], string='Status Reserve', tracking=True, copy=False, help="The current state of the stock picking.") date_reserved = fields.Datetime(string="Date Reserved", help='Tanggal ter-reserved semua barang nya', copy=False) + def action_cancel(self): + for production in self: + moves_with_forecast = production.move_raw_ids.filtered( + lambda m: m.reserved_availability > 0 + ) + + if moves_with_forecast: + # bikin list produk per baris + product_list = "\n".join( + "- %s" % p.display_name for p in moves_with_forecast.mapped('product_id') + ) + raise UserError(_( + "You cannot cancel this Manufacturing Order because the following raw materials " + "still have forecast availability:\n\n%s" % product_list + )) + return super(MrpProduction, self).action_cancel() @api.constrains('check_bom_product_lines') def constrains_check_bom_product_lines(self): |
