From c37c440f117cbb5f227096c1fceb74b2809349ee Mon Sep 17 00:00:00 2001 From: Mqdd Date: Tue, 10 Feb 2026 08:55:36 +0700 Subject: approval adjust out --- indoteknik_custom/models/stock_inventory.py | 29 +++++++++++++++++++++++++++-- indoteknik_custom/views/stock_inventory.xml | 5 +++++ 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/indoteknik_custom/models/stock_inventory.py b/indoteknik_custom/models/stock_inventory.py index 84eb5a17..c4ebaeda 100644 --- a/indoteknik_custom/models/stock_inventory.py +++ b/indoteknik_custom/models/stock_inventory.py @@ -16,6 +16,12 @@ class StockInventory(models.Model): ('in', 'Adjusment In'), ('out', 'Adjusment Out'), ], string='Adjusments Type', required=True) + approval_state = fields.Selection([ + ('draft', 'Draft'), + ('logistic', 'Logistic'), + ('accounting', 'Accounting'), + ('approved', 'Approved'), + ], default='draft', tracking=True) def _generate_number_stock_inventory(self): """Men-generate nomor untuk semua stock inventory yang belum memiliki number.""" @@ -53,8 +59,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 +78,22 @@ 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 self.approval_state in [False, '', 'draft']: + self.approval_state = 'logistic' + elif self.approval_state == 'logistic': + if not rec.env.user.has_group('indoteknik_custom.group_role_logistic'): + raise UserError("Harus diapprove logistic") + self.approval_state = 'accounting' + elif self.approval_state == 'accounting': + if not rec.env.user.has_group('indoteknik_custom.group_role_fat'): + raise UserError("Harus diapprove accounting") + self.approval_state = 'approved' + else: + raise UserError("Sudah Approved") def write(self, vals): """Jika adjusment_type diubah, generate ulang nomor.""" diff --git a/indoteknik_custom/views/stock_inventory.xml b/indoteknik_custom/views/stock_inventory.xml index db85f05c..ebbc5bb3 100644 --- a/indoteknik_custom/views/stock_inventory.xml +++ b/indoteknik_custom/views/stock_inventory.xml @@ -6,9 +6,14 @@ stock.inventory +
+
+
-- cgit v1.2.3 From b04fb88af7e868a32af5ffbe4b5f5e97a5da4878 Mon Sep 17 00:00:00 2001 From: Mqdd Date: Tue, 10 Feb 2026 09:15:30 +0700 Subject: hide approval state for adjust in --- indoteknik_custom/views/stock_inventory.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indoteknik_custom/views/stock_inventory.xml b/indoteknik_custom/views/stock_inventory.xml index ebbc5bb3..df747830 100644 --- a/indoteknik_custom/views/stock_inventory.xml +++ b/indoteknik_custom/views/stock_inventory.xml @@ -13,7 +13,7 @@ - +
-- cgit v1.2.3 From 2def9515d57eb3128cad31c8b97901055e4e0523 Mon Sep 17 00:00:00 2001 From: Mqdd Date: Tue, 10 Feb 2026 15:42:21 +0700 Subject: fix approval flow stock inventory --- indoteknik_custom/models/stock_inventory.py | 13 +++++-------- indoteknik_custom/views/stock_inventory.xml | 1 + 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/indoteknik_custom/models/stock_inventory.py b/indoteknik_custom/models/stock_inventory.py index c4ebaeda..cb7d3773 100644 --- a/indoteknik_custom/models/stock_inventory.py +++ b/indoteknik_custom/models/stock_inventory.py @@ -17,11 +17,10 @@ class StockInventory(models.Model): ('out', 'Adjusment Out'), ], string='Adjusments Type', required=True) approval_state = fields.Selection([ - ('draft', 'Draft'), ('logistic', 'Logistic'), ('accounting', 'Accounting'), ('approved', 'Approved'), - ], default='draft', tracking=True) + ], default='logistic', tracking=True) def _generate_number_stock_inventory(self): """Men-generate nomor untuk semua stock inventory yang belum memiliki number.""" @@ -82,16 +81,14 @@ class StockInventory(models.Model): def action_approve(self): if self.adjusment_type == 'out': for rec in self: - if self.approval_state in [False, '', 'draft']: - self.approval_state = 'logistic' - elif self.approval_state == 'logistic': + if rec.approval_state == 'logistic': if not rec.env.user.has_group('indoteknik_custom.group_role_logistic'): raise UserError("Harus diapprove logistic") - self.approval_state = 'accounting' - elif self.approval_state == 'accounting': + 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") - self.approval_state = 'approved' + rec.approval_state = 'approved' else: raise UserError("Sudah Approved") diff --git a/indoteknik_custom/views/stock_inventory.xml b/indoteknik_custom/views/stock_inventory.xml index df747830..89c058ea 100644 --- a/indoteknik_custom/views/stock_inventory.xml +++ b/indoteknik_custom/views/stock_inventory.xml @@ -26,6 +26,7 @@ + -- cgit v1.2.3