diff options
| author | FIN-IT_AndriFP <andrifebriyadiputra@gmail.com> | 2026-02-10 16:36:18 +0700 |
|---|---|---|
| committer | FIN-IT_AndriFP <andrifebriyadiputra@gmail.com> | 2026-02-10 16:36:18 +0700 |
| commit | 9bb9a2a0c6412ee7acb4eb1d4748e2b5301ffa21 (patch) | |
| tree | 955c2f162513854b06c695c816e7bc10502f060c | |
| parent | 30ccd81fe087eec277da6875b1df9d9a3579ab77 (diff) | |
| parent | 2def9515d57eb3128cad31c8b97901055e4e0523 (diff) | |
Merge branch 'odoo-backup' of https://bitbucket.org/altafixco/indoteknik-addons into odoo-backup
| -rw-r--r-- | indoteknik_custom/models/stock_inventory.py | 26 | ||||
| -rw-r--r-- | indoteknik_custom/views/stock_inventory.xml | 6 |
2 files changed, 30 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.""" diff --git a/indoteknik_custom/views/stock_inventory.xml b/indoteknik_custom/views/stock_inventory.xml index db85f05c..89c058ea 100644 --- a/indoteknik_custom/views/stock_inventory.xml +++ b/indoteknik_custom/views/stock_inventory.xml @@ -6,9 +6,14 @@ <field name="model">stock.inventory</field> <field name="inherit_id" ref="stock.view_inventory_form"/> <field name="arch" type="xml"> + <header> + <button name="action_approve" string="Approve" type="object" + class="btn-primary" attrs="{'invisible': [('adjusment_type', 'not in', ['out'])]}"/> + </header> <xpath expr="//field[@name='location_ids']" position="after"> <field name="number" readonly="1"/> <field name="adjusment_type" /> + <field name="approval_state" readonly="1" attrs="{'invisible': [('adjusment_type', 'not in', ['out'])]}"/> </xpath> </field> </record> @@ -21,6 +26,7 @@ <field name="arch" type="xml"> <xpath expr="//field[@name='date']" position="after"> <field name="number"/> + <field name="approval_state"/> </xpath> </field> </record> |
