summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAzka Nathan <darizkyfaz@gmail.com>2025-03-19 09:55:24 +0700
committerAzka Nathan <darizkyfaz@gmail.com>2025-03-19 09:55:24 +0700
commit9e293f201e3c43662c3866fa06eaa36805d69cc5 (patch)
tree5c09ce467cf66b39d7316025a63c324a83333d4e
parent4a7b5ebc82de37c6d2bde5e670066336256939d5 (diff)
parentf275ebcd3813e9ea7af4b61f8bb48d030ad0ccc0 (diff)
Merge branch 'odoo-backup' of bitbucket.org:altafixco/indoteknik-addons into odoo-backup
-rw-r--r--indoteknik_custom/models/stock_picking.py40
-rw-r--r--indoteknik_custom/views/stock_picking.xml16
2 files changed, 54 insertions, 2 deletions
diff --git a/indoteknik_custom/models/stock_picking.py b/indoteknik_custom/models/stock_picking.py
index 4229d33e..41f2e138 100644
--- a/indoteknik_custom/models/stock_picking.py
+++ b/indoteknik_custom/models/stock_picking.py
@@ -131,6 +131,16 @@ class StockPicking(models.Model):
('cancel', 'Cancelled'),
], string='Status Reserve', tracking=True, copy=False, help="The current state of the stock picking.")
notee = fields.Text(string="Note")
+ state_approve_md = fields.Selection([
+ ('waiting', 'Waiting For Approve by MD'),
+ ('pending', 'Pending (perlu koordinasi dengan MD)'),
+ ('done', 'Approve by MD'),
+ ], string='Approval MD Gudang Selisih', tracking=True, copy=False, help="The current state of the MD Approval transfer barang from gudang selisih.")
+ show_state_approve_md = fields.Boolean(compute="_compute_show_state_approve_md")
+
+ def _compute_show_state_approve_md(self):
+ for record in self:
+ record.show_state_approve_md = record.location_id.id == 47 or record.location_id.complete_name == "Virtual Locations/Gudang Selisih"
@api.model
def _compute_dokumen_tanda_terima(self):
@@ -881,8 +891,36 @@ class StockPicking(models.Model):
qty_onhand = check_qty_per_inventory(self, line.product_id, line.location_id)
if line.qty_done > qty_onhand:
raise UserError('Quantity Done melebihi Quantity Onhand')
+ def button_state_approve_md(self):
+ group_id = self.env.ref('indoteknik_custom.group_role_merchandiser').id
+ users_in_group = self.env['res.users'].search([('groups_id', 'in', [group_id])])
+ active_model = self.env.context.get('active_model')
+ if self.env.user.id in users_in_group.mapped('id'):
+ self.state_approve_md = 'done'
+ else:
+ raise UserError('Hanya MD yang bisa Approve')
+
+ def button_state_pending_md(self):
+ group_id = self.env.ref('indoteknik_custom.group_role_merchandiser').id
+ users_in_group = self.env['res.users'].search([('groups_id', 'in', [group_id])])
+ active_model = self.env.context.get('active_model')
+ if self.env.user.id in users_in_group.mapped('id'):
+ self.state_approve_md = 'pending'
+ else:
+ raise UserError('Hanya MD yang bisa Approve')
def button_validate(self):
+ group_id = self.env.ref('indoteknik_custom.group_role_merchandiser').id
+ users_in_group = self.env['res.users'].search([('groups_id', 'in', [group_id])])
+ active_model = self.env.context.get('active_model')
+ if self.location_id.id == 47 and self.env.user.id not in users_in_group.mapped('id') and self.state_approve_md != 'done':
+ self.state_approve_md = 'waiting' if self.state_approve_md != 'pending' else 'pending'
+ self.env.cr.commit()
+ raise UserError("Transfer dari gudang selisih harus di approve MD, Hubungi MD agar bisa di Validate")
+ else:
+ if self.location_id.id == 47 and self.env.user.id in users_in_group.mapped('id'):
+ self.state_approve_md = 'done'
+
if not self.env.user.is_logistic_approver and self.env.context.get('active_model') == 'stock.picking':
if self.origin and 'Return of' in self.origin:
raise UserError("Button ini hanya untuk Logistik")
@@ -907,7 +945,7 @@ class StockPicking(models.Model):
if self.picking_type_id.id == 28 and not self.env.user.is_logistic_approver:
raise UserError("Harus di Approve oleh Logistik")
-
+
if self.location_dest_id.id == 47 and not self.env.user.is_purchasing_manager:
raise UserError("Transfer ke gudang selisih harus di approve Rafly Hanggara")
diff --git a/indoteknik_custom/views/stock_picking.xml b/indoteknik_custom/views/stock_picking.xml
index dadd5021..ce07888a 100644
--- a/indoteknik_custom/views/stock_picking.xml
+++ b/indoteknik_custom/views/stock_picking.xml
@@ -19,7 +19,8 @@
<field name="note" optional="hide"/>
<field name="date_reserved" optional="hide"/>
<field name="state_reserve" optional="hide"/>
- <field name="final_seq"/>
+ <field name="final_seq"/>
+<!-- <field name="state_approve_md" widget="badge" decoration-success="state_approve_md == 'done'" decoration-warning="state_approve_md == 'pending'" />-->
<!-- <field name="countdown_hours" optional="hide"/>
<field name="countdown_ready_to_ship" /> -->
</field>
@@ -70,6 +71,17 @@
type="object"
attrs="{'invisible': [('carrier_id', '!=', 9)]}"
/>
+<!-- <button name="button_state_approve_md"-->
+<!-- string="Approve MD Gudang Selisih"-->
+<!-- type="object"-->
+<!-- attrs="{'invisible': [('state_approve_md', 'not in', ['waiting', 'pending'])]}"-->
+<!-- />-->
+
+<!-- <button name="button_state_pending_md"-->
+<!-- string="Pending MD Gudang Selisih"-->
+<!-- type="object"-->
+<!-- attrs="{'invisible': [('state_approve_md', 'not in', ['waiting'])]}"-->
+<!-- />-->
</button>
<field name="backorder_id" position="after">
<field name="summary_qty_detail"/>
@@ -97,6 +109,8 @@
<field name="arrival_time"/>
</field>
<field name="origin" position="after">
+<!-- <field name="show_state_approve_md" invisible="1" optional="hide"/>-->
+<!-- <field name="state_approve_md" widget="badge" attrs="{'invisible': [('show_state_approve_md', '=', False)]}"/>-->
<field name="purchase_id"/>
<field name="sale_order"/>
<field name="invoice_status"/>