From 459e34a6f96ed12522036bb12da2e0488581c016 Mon Sep 17 00:00:00 2001 From: Miqdad Date: Fri, 7 Nov 2025 13:16:34 +0700 Subject: CR nathan stock picking --- indoteknik_custom/models/sale_order.py | 1 + indoteknik_custom/models/stock_picking.py | 22 ++++++++++++++++++++-- indoteknik_custom/views/sale_order.xml | 1 + indoteknik_custom/views/stock_picking.xml | 5 +++-- 4 files changed, 25 insertions(+), 4 deletions(-) diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py index 31662fb4..ef6318da 100755 --- a/indoteknik_custom/models/sale_order.py +++ b/indoteknik_custom/models/sale_order.py @@ -398,6 +398,7 @@ class SaleOrder(models.Model): compute="_compute_partner_is_cbd_locked" ) internal_notes_contact = fields.Text(related='partner_id.comment', string="Internal Notes", readonly=True, help="Internal Notes dari contact utama customer.") + is_so_fiktif = fields.Boolean('SO Fiktif?') def action_open_partial_delivery_wizard(self): # raise UserError("Fitur ini sedang dalam pengembangan") diff --git a/indoteknik_custom/models/stock_picking.py b/indoteknik_custom/models/stock_picking.py index c17fdbd5..8fefcf81 100644 --- a/indoteknik_custom/models/stock_picking.py +++ b/indoteknik_custom/models/stock_picking.py @@ -199,14 +199,19 @@ class StockPicking(models.Model): ('full', 'Full'), ], string='Delivery Status', compute='_compute_delivery_status_detail', store=False) so_num = fields.Char('SO Number', compute='_get_so_num') + is_so_fiktif = fields.Boolean('SO Fiktif?', compute='_compute_is_so_fiktif') + + @api.depends('sale_id.is_so_fiktif') + def _compute_is_so_fiktif(self): + for picking in self: + picking.is_so_fiktif = picking.sale_id.is_so_fiktif if picking.sale_id else False + @api.depends('group_id') def _get_so_num(self): for record in self: record.so_num = record.group_id.name - - @api.depends('move_line_ids_without_package.qty_done', 'move_line_ids_without_package.product_uom_qty', 'state') def _compute_delivery_status_detail(self): for picking in self: @@ -1383,6 +1388,8 @@ class StockPicking(models.Model): 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.is_so_fiktif == True: + raise UserError("SO Fiktif tidak bisa di validate") 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' @@ -1562,6 +1569,10 @@ class StockPicking(models.Model): elif self.tukar_guling_po_id: self.tukar_guling_po_id.update_doc_state() + user = self.env.user + if not user.has_group('indoteknik_custom.group_role_logistic'): + raise UserWarning('Validate hnaya bisa di lakukan oleh logistik') + return res def automatic_reserve_product(self): @@ -1732,6 +1743,13 @@ class StockPicking(models.Model): 'indoteknik_custom.group_role_logistic') and self.picking_type_code == 'outgoing': raise UserError("Button ini hanya untuk Logistik") + if len(self.check_product_lines) >= 1: + raise UserError("Tidak Bisa cancel karena sudah di check product") + + if not self.env.user.is_logistic_approver and not self.env.user.has_group('indoteknik_custom.group_role_logistic'): + if self.name and ('BU/PICK' in self.name or 'BU/OUT' in self.name or 'BU/ORT' in self.name or 'BU/SRT' in self.name): + raise UserError("Button ini hanya untuk Logistik") + res = super(StockPicking, self).action_cancel() return res diff --git a/indoteknik_custom/views/sale_order.xml b/indoteknik_custom/views/sale_order.xml index a540caa7..b2ecc21c 100755 --- a/indoteknik_custom/views/sale_order.xml +++ b/indoteknik_custom/views/sale_order.xml @@ -130,6 +130,7 @@ + 1 diff --git a/indoteknik_custom/views/stock_picking.xml b/indoteknik_custom/views/stock_picking.xml index cc9469cb..8e1e9d3e 100644 --- a/indoteknik_custom/views/stock_picking.xml +++ b/indoteknik_custom/views/stock_picking.xml @@ -147,7 +147,7 @@ {'readonly': [('parent.picking_type_code', '=', 'incoming')]} --> - + 1 @@ -162,11 +162,12 @@ - + + -- cgit v1.2.3