diff options
| author | stephanchrst <stephanchrst@gmail.com> | 2023-05-22 15:09:56 +0700 |
|---|---|---|
| committer | stephanchrst <stephanchrst@gmail.com> | 2023-05-22 15:09:56 +0700 |
| commit | 38372fa34198830ea675a471d25cc3523bb1531a (patch) | |
| tree | 3526690a8fe0fbbf467df4cf1f93677da0229b35 | |
| parent | 752db0759177d9e804e9b57ed87e40676a4bcc5d (diff) | |
unbuild validation for prevent negative inventory finished good
| -rw-r--r-- | indoteknik_custom/models/manufacturing.py | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/indoteknik_custom/models/manufacturing.py b/indoteknik_custom/models/manufacturing.py index 4dbf2605..15756e44 100644 --- a/indoteknik_custom/models/manufacturing.py +++ b/indoteknik_custom/models/manufacturing.py @@ -6,6 +6,7 @@ _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': @@ -31,4 +32,15 @@ class Manufacturing(models.Model): result = super(Manufacturing, self).button_mark_done() return result -
\ No newline at end of file + + 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() + return result |
