summaryrefslogtreecommitdiff
path: root/indoteknik_custom/models
diff options
context:
space:
mode:
authorMqdd <ahmadmiqdad27@gmail.com>2026-02-16 13:34:38 +0700
committerMqdd <ahmadmiqdad27@gmail.com>2026-02-16 13:34:38 +0700
commite6058c804068e5208581bbd18d2dbbe98c63ba26 (patch)
treee567e8313acf42f65458c2795f11b9644f0b90f5 /indoteknik_custom/models
parent2cf62d4c23e8fbd0770ba05cb4d1f65032bccdf0 (diff)
parentc08d16f53c4e2c97e74f33018e00efabd08664b3 (diff)
Merge branch 'gudang-service' of bitbucket.org:altafixco/indoteknik-addons into gudang-service
Diffstat (limited to 'indoteknik_custom/models')
-rw-r--r--indoteknik_custom/models/gudang_service.py31
-rwxr-xr-xindoteknik_custom/models/sale_order.py14
-rw-r--r--indoteknik_custom/models/stock_inventory.py44
3 files changed, 53 insertions, 36 deletions
diff --git a/indoteknik_custom/models/gudang_service.py b/indoteknik_custom/models/gudang_service.py
index b7ccc44f..bd8ec8bd 100644
--- a/indoteknik_custom/models/gudang_service.py
+++ b/indoteknik_custom/models/gudang_service.py
@@ -81,9 +81,9 @@ class GudangService(models.Model):
return
users = group.users
- # Safa
- md = self.env["res.users"].browse([3425])
- # send to logistic and safa
+ # MD
+ md = self.env['res.users'].browse([3425, 4801, 1036])
+ # send to logistic and MD
users = users | md
if not users:
@@ -176,21 +176,16 @@ class GudangService(models.Model):
rec.state = "received_from_vendor"
def action_done(self):
- if self.state != "received_from_vendor":
- raise UserError("Only 'Received From Vendor' state can be set to Done")
- else:
- for rec in self:
- activities = self.env["mail.activity"].search(
- [
- ("res_id", "=", rec.id),
- ("res_model", "=", "gudang.service"),
- ("state", "=", "delivered_to_cust"),
- ]
- )
- activities.unlink()
- rec.state = "delivered_to_cust"
- if not rec.done_date:
- rec.done_date = fields.Datetime.now()
+ for rec in self:
+ if rec.state != 'received_from_vendor':
+ raise UserError("Only 'Received From Vendor' state can be set to Done")
+
+ rec.activity_ids.unlink()
+
+ rec.write({
+ 'state': 'delivered_to_cust',
+ 'done_date': fields.Datetime.now()
+ })
def action_draft(self):
"""Reset to draft state"""
diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py
index 49e36279..2548c7b3 100755
--- a/indoteknik_custom/models/sale_order.py
+++ b/indoteknik_custom/models/sale_order.py
@@ -2598,6 +2598,18 @@ class SaleOrder(models.Model):
else:
return False
+ def check_archived_product(self):
+ for order in self:
+ for line in order.order_line:
+ if line.product_id.active == False:
+ raise UserError("Terdapat Product yang sudah di Archive pada Product: {}".format(line.product_id.display_name))
+
+ def check_archived_uom(self):
+ for order in self:
+ for line in order.order_line:
+ if line.product_uom.active == False:
+ raise UserError("Terdapat UoM yang sudah di Archive pada UoM {} di Product {}".format(line.product_uom.name, line.product_id.display_name))
+
def action_confirm(self):
for order in self:
order._validate_delivery_amt()
@@ -2614,6 +2626,8 @@ class SaleOrder(models.Model):
order._validate_order()
order._validate_npwp()
order.order_line.validate_line()
+ order.check_archived_product()
+ order.check_archived_uom()
main_parent = order.partner_id.get_main_parent()
SYSTEM_UID = 25
diff --git a/indoteknik_custom/models/stock_inventory.py b/indoteknik_custom/models/stock_inventory.py
index cb7d3773..b3580a4c 100644
--- a/indoteknik_custom/models/stock_inventory.py
+++ b/indoteknik_custom/models/stock_inventory.py
@@ -16,11 +16,35 @@ 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)
+ ], default='logistic', tracking=True, readonly=True)
+
+ def action_validate(self):
+ if self.adjusment_type == 'out':
+
+ if self.approval_state != 'approved':
+
+ if self.approval_state == 'logistic':
+ if not self.env.user.has_group('indoteknik_custom.group_role_logistic'):
+ raise UserError("Adjustment Out harus dilakukan oleh Logistic")
+ self.approval_state = 'accounting'
+ return True
+
+ elif self.approval_state == 'accounting':
+ if not self.env.user.has_group('indoteknik_custom.group_role_fat'):
+ raise UserError("Adjustment Out harus dilakukan oleh Accounting")
+ self.approval_state = 'approved'
+ return True
+
+ else:
+ raise UserError("Adjustment Out harus melalui approval terlebih dahulu.")
+
+ return super(StockInventory, self).action_validate()
+
def _generate_number_stock_inventory(self):
"""Men-generate nomor untuk semua stock inventory yang belum memiliki number."""
@@ -58,10 +82,7 @@ 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 [21, 17, 571, 28]:
+ if self.env.user.id not in [21, 17, 571, 28, 25]:
raise UserError("Hanya Rafly, Denise, Iqmal, dan Stephan yang bisa start inventory")
return super(StockInventory, self).action_start()
@@ -78,19 +99,6 @@ class StockInventory(models.Model):
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."""