summaryrefslogtreecommitdiff
path: root/fixco_custom
diff options
context:
space:
mode:
authorMqdd <ahmadmiqdad27@gmail.com>2026-02-15 17:29:54 +0700
committerMqdd <ahmadmiqdad27@gmail.com>2026-02-15 17:29:54 +0700
commitf24d7fc1c60fb0198dbb62f7ba996912ce9f2b9d (patch)
treecf73b538781796e221fff0a56d100f4f82173b19 /fixco_custom
parent23df914163b59d27c32e319f43ca8539a3e456cc (diff)
<Miqdad> fix flow adjusment out
Diffstat (limited to 'fixco_custom')
-rw-r--r--fixco_custom/models/stock_inventory.py56
-rw-r--r--fixco_custom/views/stock_inventory.xml4
2 files changed, 35 insertions, 25 deletions
diff --git a/fixco_custom/models/stock_inventory.py b/fixco_custom/models/stock_inventory.py
index 1a8f3b0..e507af5 100644
--- a/fixco_custom/models/stock_inventory.py
+++ b/fixco_custom/models/stock_inventory.py
@@ -20,7 +20,7 @@ class StockInventory(models.Model):
('logistic', 'Logistic'),
('accounting', 'Accounting'),
('approved', 'Approved'),
- ], default='logistic', tracking=True)
+ ], tracking=True)
def _generate_number_stock_inventory(self):
"""Men-generate nomor untuk semua stock inventory yang belum memiliki number."""
@@ -58,46 +58,60 @@ class StockInventory(models.Model):
return "00001" # Jika belum ada data, mulai dari 00001
def action_start(self):
- 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 [10, 14, 20, 21]:
- raise UserError("Hanya User tertentu yang dapat melakukan Adjust-In")
+ if self.env.user.id not in [10, 14, 20, 21, 15]:
+ raise UserError("Hanya User tertentu yang dapat melakukan Adjust-In/Out")
return super(StockInventory, self).action_start()
@api.model
def create(self, vals):
"""Pastikan nomor hanya dibuat saat penyimpanan."""
+
+ if vals.get('adjusment_type') == 'in':
+ vals['approval_state'] = False
+ elif vals.get('adjusment_type') == 'out':
+ vals['approval_state'] = 'logistic'
+
if 'adjusment_type' in vals and not vals.get('number'):
- vals['number'] = False # Jangan buat number otomatis dulu
+ vals['number'] = False
order = super(StockInventory, self).create(vals)
if order.adjusment_type:
- self._assign_number(order) # Generate number setelah save
+ self._assign_number(order)
return order
-
- def action_approve(self):
+
+ def action_validate(self):
if self.adjusment_type == 'out':
- for rec in self:
- if rec.approval_state == 'logistic':
- if not rec.env.user.id in [10, 14, 20, 21]:
- raise UserError("Harus diapprove logistic")
- rec.approval_state = 'accounting'
- elif rec.approval_state == 'accounting':
- if not rec.env.user.id in [13, 24, 2]:
- raise UserError("Harus diapprove accounting")
- rec.approval_state = 'approved'
+
+ if self.approval_state != 'approved':
+
+ if self.approval_state == 'logistic':
+ if not self.env.user.id in [10, 14, 20, 21]:
+ raise UserError("Adjustment Out harus diapprove oleh Logistic")
+ self.approval_state = 'accounting'
+ return True
+
+ elif self.approval_state == 'accounting':
+ if not self.env.user.id in [13, 24, 2]:
+ raise UserError("Adjustment Out harus diapprove oleh Accounting")
+ self.approval_state = 'approved'
+ return super(StockInventory, self).action_validate()
+
else:
- raise UserError("Sudah Approved")
+ raise UserError("Adjustment Out harus melalui approval terlebih dahulu.")
+
+ return super(StockInventory, self).action_validate()
def write(self, vals):
"""Jika adjusment_type diubah, generate ulang nomor."""
res = super(StockInventory, self).write(vals)
if 'adjusment_type' in vals:
for record in self:
- self._assign_number(record)
+ if record.adjusment_type == 'in':
+ record.approval_state = False
+ elif record.adjusment_type == 'out' and record.approval_state == False:
+ record.approval_state = 'logistic'
return res
def copy(self, default=None):
diff --git a/fixco_custom/views/stock_inventory.xml b/fixco_custom/views/stock_inventory.xml
index 89c058e..a343db3 100644
--- a/fixco_custom/views/stock_inventory.xml
+++ b/fixco_custom/views/stock_inventory.xml
@@ -6,10 +6,6 @@
<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" />