summaryrefslogtreecommitdiff
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
parent2cf62d4c23e8fbd0770ba05cb4d1f65032bccdf0 (diff)
parentc08d16f53c4e2c97e74f33018e00efabd08664b3 (diff)
Merge branch 'gudang-service' of bitbucket.org:altafixco/indoteknik-addons into gudang-service
-rwxr-xr-xindoteknik_custom/__manifest__.py4
-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
-rw-r--r--indoteknik_custom/views/gudang_service.xml2
-rw-r--r--indoteknik_custom/views/stock_inventory.xml7
6 files changed, 58 insertions, 44 deletions
diff --git a/indoteknik_custom/__manifest__.py b/indoteknik_custom/__manifest__.py
index 6287aace..fd6f3140 100755
--- a/indoteknik_custom/__manifest__.py
+++ b/indoteknik_custom/__manifest__.py
@@ -194,8 +194,8 @@
'views/domain_apo.xml',
'views/uom_uom.xml',
'views/commission_internal.xml',
- 'views/gudang_service.xml',
- 'views/update_depreciation_move_wizard_view.xml'
+ 'views/update_depreciation_move_wizard_view.xml',
+ 'views/gudang_service.xml'
],
'demo': [],
'css': [],
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."""
diff --git a/indoteknik_custom/views/gudang_service.xml b/indoteknik_custom/views/gudang_service.xml
index e5cc94c4..769664c5 100644
--- a/indoteknik_custom/views/gudang_service.xml
+++ b/indoteknik_custom/views/gudang_service.xml
@@ -54,7 +54,7 @@
<field name="partner_id"/>
<field name="vendor_id"/>
<field name="remaining_date"/>
- <field name="schedule_date" attrs="{'readonly': [('state', 'not in', ['draft'])]}"/>
+ <field name="schedule_date" attrs="{'readonly': [('state', 'not in', ['draft', 'reveived_from_cust'])]}"/>
<field name="start_date" readonly="1"/>
<field name="done_date" attrs="{'invisible': [('state', 'not in', ['delivered_to_cust'])]}"/>
<field name="create_uid"/>
diff --git a/indoteknik_custom/views/stock_inventory.xml b/indoteknik_custom/views/stock_inventory.xml
index 89c058ea..ab1b6eec 100644
--- a/indoteknik_custom/views/stock_inventory.xml
+++ b/indoteknik_custom/views/stock_inventory.xml
@@ -6,14 +6,10 @@
<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'])]}"/>
+ <field name="approval_state" />
</xpath>
</field>
</record>
@@ -26,6 +22,7 @@
<field name="arch" type="xml">
<xpath expr="//field[@name='date']" position="after">
<field name="number"/>
+ <field name="adjusment_type" />
<field name="approval_state"/>
</xpath>
</field>