summaryrefslogtreecommitdiff
path: root/indoteknik_custom/models
diff options
context:
space:
mode:
authorMqdd <ahmadmiqdad27@gmail.com>2026-02-10 08:55:36 +0700
committerMqdd <ahmadmiqdad27@gmail.com>2026-02-10 08:55:36 +0700
commitc37c440f117cbb5f227096c1fceb74b2809349ee (patch)
tree7f12da0c93906fc9ad0d3d5af090bfcf7e4a65df /indoteknik_custom/models
parenta0988c45dba1451dc5a670eb6a378527de1390ec (diff)
<Miqdad> approval adjust out
Diffstat (limited to 'indoteknik_custom/models')
-rw-r--r--indoteknik_custom/models/stock_inventory.py29
1 files changed, 27 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."""