diff options
| author | Mqdd <ahmadmiqdad27@gmail.com> | 2026-02-14 11:14:01 +0700 |
|---|---|---|
| committer | Mqdd <ahmadmiqdad27@gmail.com> | 2026-02-14 11:14:01 +0700 |
| commit | 472f36669375d3d0bcecf137e07260fac25d12b3 (patch) | |
| tree | 873a665fd8d3cc249a6460858e85272b838162d3 /indoteknik_custom/models/stock_inventory.py | |
| parent | 24b33148858c9827ad0b14e716562c377e1644ca (diff) | |
| parent | 37e0beac646ee2e676ff935e8289cf3189b3c21b (diff) | |
Merge branch 'odoo-backup' of https://bitbucket.org/altafixco/indoteknik-addons into gudang-service
Diffstat (limited to 'indoteknik_custom/models/stock_inventory.py')
| -rw-r--r-- | indoteknik_custom/models/stock_inventory.py | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/indoteknik_custom/models/stock_inventory.py b/indoteknik_custom/models/stock_inventory.py index 84eb5a17..cb7d3773 100644 --- a/indoteknik_custom/models/stock_inventory.py +++ b/indoteknik_custom/models/stock_inventory.py @@ -16,6 +16,11 @@ class StockInventory(models.Model): ('in', 'Adjusment In'), ('out', 'Adjusment Out'), ], string='Adjusments Type', required=True) + approval_state = fields.Selection([ + ('logistic', 'Logistic'), + ('accounting', 'Accounting'), + ('approved', 'Approved'), + ], default='logistic', tracking=True) def _generate_number_stock_inventory(self): """Men-generate nomor untuk semua stock inventory yang belum memiliki number.""" @@ -53,8 +58,11 @@ class StockInventory(models.Model): return "00001" # Jika belum ada data, mulai dari 00001 def action_start(self): - if self.env.user.id not in [21, 17, 571, 28]: - raise UserError("Hanya Rafly, Denise, Iqmal, dan Stephan yang bisa start inventory") + if self.approval_state != 'approved' and self.adjusment_type == 'out': + raise UserError('Harus melalui proses approval') + if self.adjusment_type == 'in': + if self.env.user.id not in [21, 17, 571, 28]: + raise UserError("Hanya Rafly, Denise, Iqmal, dan Stephan yang bisa start inventory") return super(StockInventory, self).action_start() @api.model @@ -69,6 +77,20 @@ class StockInventory(models.Model): self._assign_number(order) # Generate number setelah save return order + + def action_approve(self): + if self.adjusment_type == 'out': + for rec in self: + if rec.approval_state == 'logistic': + if not rec.env.user.has_group('indoteknik_custom.group_role_logistic'): + raise UserError("Harus diapprove logistic") + rec.approval_state = 'accounting' + elif rec.approval_state == 'accounting': + if not rec.env.user.has_group('indoteknik_custom.group_role_fat'): + raise UserError("Harus diapprove accounting") + rec.approval_state = 'approved' + else: + raise UserError("Sudah Approved") def write(self, vals): """Jika adjusment_type diubah, generate ulang nomor.""" |
