From ae360ebbe575c5ede395b0b396b9627b89b0e226 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Thu, 2 Oct 2025 13:53:42 +0700 Subject: fix bug --- indoteknik_custom/models/stock_picking.py | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'indoteknik_custom/models/stock_picking.py') diff --git a/indoteknik_custom/models/stock_picking.py b/indoteknik_custom/models/stock_picking.py index 16e235da..ae7121da 100644 --- a/indoteknik_custom/models/stock_picking.py +++ b/indoteknik_custom/models/stock_picking.py @@ -2552,9 +2552,22 @@ class ScanKoli(models.Model): out_moves = self.env['stock.move.line'].search([('picking_id', '=', picking.linked_out_picking_id.id)]) for pick_move in pick_moves: - corresponding_out_move = out_moves.filtered(lambda m: m.product_id == pick_move.product_id) - if corresponding_out_move: - corresponding_out_move.qty_done += pick_move.qty_done + corresponding_out_moves = out_moves.filtered(lambda m: m.product_id == pick_move.product_id) + + if len(corresponding_out_moves) == 1: + corresponding_out_moves.qty_done += pick_move.qty_done + + elif len(corresponding_out_moves) > 1: + qty_koli = pick_move.qty_done + for out_move in corresponding_out_moves: + if qty_koli <= 0: + break + # ambil sesuai kebutuhan atau sisa qty + qty_to_assign = min(qty_koli, out_move.product_uom_qty) + out_move.qty_done += qty_to_assign + qty_koli -= qty_to_assign + + def _reset_qty_done_if_no_scan(self, picking_id): product_bu_pick = self.env['stock.move.line'].search([('picking_id', '=', picking_id)]) -- cgit v1.2.3 From baaaa901391b4cd6956cb28aff992735e84962e4 Mon Sep 17 00:00:00 2001 From: Miqdad Date: Fri, 3 Oct 2025 19:38:57 +0700 Subject: CR BU/IU Approval flow --- indoteknik_custom/models/stock_picking.py | 46 +++++++++++++++++++++++-------- 1 file changed, 34 insertions(+), 12 deletions(-) (limited to 'indoteknik_custom/models/stock_picking.py') diff --git a/indoteknik_custom/models/stock_picking.py b/indoteknik_custom/models/stock_picking.py index ae7121da..eea87926 100644 --- a/indoteknik_custom/models/stock_picking.py +++ b/indoteknik_custom/models/stock_picking.py @@ -176,6 +176,28 @@ class StockPicking(models.Model): linked_manual_bu_out = fields.Many2one('stock.picking', string='BU Out', copy=False) area_name = fields.Char(string="Area", compute="_compute_area_name") + is_bu_iu = fields.Boolean('Is BU/IU', compute='_compute_is_bu_iu', default=False, copy=False, readonl=True) + + @api.depends('name') + def _compute_is_bu_iu(self): + for record in self: + if 'BU/IU' in record.name: + record.is_bu_iu = True + else: + record.is_bu_iu = False + + def action_bu_iu_to_pengajuan2(self): + for rec in self: + if not rec.is_bu_iu or not rec.is_internal_use: + raise UserError(_("Tombol ini hanya untuk dokumen BU/IU - Internal Use.")) + if rec.approval_status == False: + raise UserError("Harus Ask Approval terlebih dahulu") + if rec.approval_status in ['pengajuan1'] and self.env.user.is_accounting: + rec.approval_status = 'pengajuan2' + # raise UserError(_("Hanya bisa dijalankan saat status di 'pengajuan1'.")) + rec.message_post(body=_("Status naik ke Approval Logistik oleh %s") % self.env.user.display_name) + + return True # def _get_biteship_api_key(self): # # return self.env['ir.config_parameter'].sudo().get_param('biteship.api_key_test') @@ -1082,9 +1104,12 @@ class StockPicking(models.Model): def ask_approval(self): - if self.env.user.is_accounting: - raise UserError("Bisa langsung Validate") - if self.env.user.is_logistic_approver and self.location_id.id == 57 or self.location_id== 57: + # if self.env.user.is_accounting: + # if self.env.user.is_accounting and self.location_id.id == 57 or self.location_id == 57 and self.approval_status in ['pengajuan1', ''] and 'BU/IU' in self.name and self.approval_status == 'pengajuan1': + # raise UserError("Bisa langsung set ke approval logistik") + if self.env.user.is_accounting and self.approval_status == "pengajuan2" and 'BU/IU' in self.name: + raise UserError("Tidak perlu ask approval sudah approval logistik") + if self.env.user.is_logistic_approver and self.location_id.id == 57 or self.location_id== 57 and self.approval_status == 'pengajuan2' and 'BU/IU' in self.name: raise UserError("Bisa langsung Validate") @@ -1110,9 +1135,7 @@ class StockPicking(models.Model): if line.qty_done <= 0: raise UserError("Qty tidak boleh 0") pick.approval_status = 'pengajuan1' - if pick.location_id.id == 57: - pick.approval_status = 'pengajuan2' - return + def ask_receipt_approval(self): if self.env.user.is_logistic_approver: @@ -1315,10 +1338,10 @@ class StockPicking(models.Model): if self.picking_type_id.code == 'incoming' and self.group_id.id == False and self.is_internal_use == False: raise UserError(_('Tidak bisa Validate jika tidak dari Document SO / PO')) - if self.is_internal_use and not self.env.user.is_logistic_approver and self.location_id.id == 57: + if self.is_internal_use and not self.env.user.is_logistic_approver and self.location_id.id == 57 and self.approval_status == 'pengajuan2': raise UserError("Harus di Approve oleh Logistik") - if self.is_internal_use and not self.env.user.is_accounting: + if self.is_internal_use and not self.env.user.is_accounting and self.approval_status == 'pengajuan1' and self.location_id.id == 57: raise UserError("Harus di Approve oleh Accounting") if self.picking_type_id.id == 28 and not self.env.user.is_logistic_approver: @@ -1327,8 +1350,10 @@ class StockPicking(models.Model): 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") - if self.is_internal_use: + if self.is_internal_use and self.approval_status == 'pengajuan2': self.approval_status = 'approved' + elif self.is_internal_use and self.approval_status in ['pengajuan1', '', False]: + raise UserError("Tidak Bisa Validate, set approval status ke approval logistik terlebih dahhulu") elif self.picking_type_id.code == 'incoming': self.approval_receipt_status = 'approved' @@ -1360,9 +1385,6 @@ class StockPicking(models.Model): ) self.validation_minus_onhand_quantity() - loc = self.location_id - if loc.id == 57 and not self.env.user.is_logistic_approver and self.approval_status in ['pengajuan2']: - raise UserError ("Harus Ask Approval Logistik") self.responsible = self.env.user.id # self.send_koli_to_so() if self.picking_type_code == 'outgoing' and 'BU/OUT/' in self.name: -- cgit v1.2.3 From 63bb46e84f44bdcb286bbca544f65b03a7d98636 Mon Sep 17 00:00:00 2001 From: Miqdad Date: Mon, 6 Oct 2025 09:05:59 +0700 Subject: rollback --- indoteknik_custom/models/stock_picking.py | 67 +++++++------------------------ 1 file changed, 14 insertions(+), 53 deletions(-) (limited to 'indoteknik_custom/models/stock_picking.py') diff --git a/indoteknik_custom/models/stock_picking.py b/indoteknik_custom/models/stock_picking.py index eea87926..43e45c09 100644 --- a/indoteknik_custom/models/stock_picking.py +++ b/indoteknik_custom/models/stock_picking.py @@ -176,28 +176,6 @@ class StockPicking(models.Model): linked_manual_bu_out = fields.Many2one('stock.picking', string='BU Out', copy=False) area_name = fields.Char(string="Area", compute="_compute_area_name") - is_bu_iu = fields.Boolean('Is BU/IU', compute='_compute_is_bu_iu', default=False, copy=False, readonl=True) - - @api.depends('name') - def _compute_is_bu_iu(self): - for record in self: - if 'BU/IU' in record.name: - record.is_bu_iu = True - else: - record.is_bu_iu = False - - def action_bu_iu_to_pengajuan2(self): - for rec in self: - if not rec.is_bu_iu or not rec.is_internal_use: - raise UserError(_("Tombol ini hanya untuk dokumen BU/IU - Internal Use.")) - if rec.approval_status == False: - raise UserError("Harus Ask Approval terlebih dahulu") - if rec.approval_status in ['pengajuan1'] and self.env.user.is_accounting: - rec.approval_status = 'pengajuan2' - # raise UserError(_("Hanya bisa dijalankan saat status di 'pengajuan1'.")) - rec.message_post(body=_("Status naik ke Approval Logistik oleh %s") % self.env.user.display_name) - - return True # def _get_biteship_api_key(self): # # return self.env['ir.config_parameter'].sudo().get_param('biteship.api_key_test') @@ -213,7 +191,7 @@ class StockPicking(models.Model): # def write(self, vals): # if 'linked_manual_bu_out' in vals: # for record in self: - # if (record.picking_type_code == 'internal' + # if (record.picking_type_code == 'internal' # and 'BU/PICK/' in record.name): # # Jika menghapus referensi (nilai di-set False/None) # if record.linked_manual_bu_out and not vals['linked_manual_bu_out']: @@ -227,8 +205,8 @@ class StockPicking(models.Model): # @api.model # def create(self, vals): # record = super().create(vals) - # if (record.picking_type_code == 'internal' - # and 'BU/PICK/' in record.name + # if (record.picking_type_code == 'internal' + # and 'BU/PICK/' in record.name # and vals.get('linked_manual_bu_out')): # picking = self.env['stock.picking'].browse(vals['linked_manual_bu_out']) # picking.state_packing = 'packing_done' @@ -365,7 +343,6 @@ class StockPicking(models.Model): except ValueError: return False - def action_get_kgx_pod(self, shipment=False): self.ensure_one() @@ -533,7 +510,7 @@ class StockPicking(models.Model): # rts_days = rts.days # rts_hours = divmod(rts.seconds, 3600) - # estimated_by_erts = rts.total_seconds() / 3600 + # estimated_by_erts = rts.total_seconds() / 3600 # record.countdown_ready_to_ship = f"{rts_days} days, {rts_hours} hours" # record.countdown_hours = estimated_by_erts @@ -1086,7 +1063,8 @@ class StockPicking(models.Model): self.sale_id.date_doc_kirim = self.date_doc_kirim def action_assign(self): - if self.env.context.get('default_picking_type_id') and ('BU/INPUT' not in self.name or 'BU/PUT' not in self.name): + if self.env.context.get('default_picking_type_id') and ( + 'BU/INPUT' not in self.name or 'BU/PUT' not in self.name): pickings_to_assign = self.filtered( lambda p: not (p.sale_id and p.sale_id.hold_outgoing) ) @@ -1102,18 +1080,10 @@ class StockPicking(models.Model): return res - def ask_approval(self): - # if self.env.user.is_accounting: - # if self.env.user.is_accounting and self.location_id.id == 57 or self.location_id == 57 and self.approval_status in ['pengajuan1', ''] and 'BU/IU' in self.name and self.approval_status == 'pengajuan1': - # raise UserError("Bisa langsung set ke approval logistik") - if self.env.user.is_accounting and self.approval_status == "pengajuan2" and 'BU/IU' in self.name: - raise UserError("Tidak perlu ask approval sudah approval logistik") - if self.env.user.is_logistic_approver and self.location_id.id == 57 or self.location_id== 57 and self.approval_status == 'pengajuan2' and 'BU/IU' in self.name: + if self.env.user.is_accounting: raise UserError("Bisa langsung Validate") - - # for calendar distribute only # if self.is_internal_use: # stock_move_lines = self.env['stock.move.line'].search([ @@ -1136,7 +1106,6 @@ class StockPicking(models.Model): raise UserError("Qty tidak boleh 0") pick.approval_status = 'pengajuan1' - def ask_receipt_approval(self): if self.env.user.is_logistic_approver: raise UserError('Bisa langsung validate tanpa Ask Receipt') @@ -1338,10 +1307,7 @@ class StockPicking(models.Model): if self.picking_type_id.code == 'incoming' and self.group_id.id == False and self.is_internal_use == False: raise UserError(_('Tidak bisa Validate jika tidak dari Document SO / PO')) - if self.is_internal_use and not self.env.user.is_logistic_approver and self.location_id.id == 57 and self.approval_status == 'pengajuan2': - raise UserError("Harus di Approve oleh Logistik") - - if self.is_internal_use and not self.env.user.is_accounting and self.approval_status == 'pengajuan1' and self.location_id.id == 57: + if self.is_internal_use and not self.env.user.is_accounting: raise UserError("Harus di Approve oleh Accounting") if self.picking_type_id.id == 28 and not self.env.user.is_logistic_approver: @@ -1350,10 +1316,8 @@ class StockPicking(models.Model): 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") - if self.is_internal_use and self.approval_status == 'pengajuan2': + if self.is_internal_use: self.approval_status = 'approved' - elif self.is_internal_use and self.approval_status in ['pengajuan1', '', False]: - raise UserError("Tidak Bisa Validate, set approval status ke approval logistik terlebih dahhulu") elif self.picking_type_id.code == 'incoming': self.approval_receipt_status = 'approved' @@ -1369,7 +1333,6 @@ class StockPicking(models.Model): current_time = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S') self.date_reserved = current_time - # Validate Qty Demand Can't higher than Qty Product if self.location_dest_id.id == 58 and 'BU/INPUT/' in self.name: for move in self.move_ids_without_package: @@ -1390,14 +1353,14 @@ class StockPicking(models.Model): if self.picking_type_code == 'outgoing' and 'BU/OUT/' in self.name: self.check_koli() res = super(StockPicking, self).button_validate() - + # Penambahan link PO di Stock Journal untuk Picking BD for picking in self: if picking.name and 'BD/' in picking.name and picking.purchase_id: stock_journal = self.env['account.move'].search([ ('ref', 'ilike', picking.name + '%'), - ('journal_id', '=', 3) # Stock Journal ID - ], limit = 1) + ('journal_id', '=', 3) # Stock Journal ID + ], limit=1) if stock_journal: stock_journal.write({ 'purchase_order_id': picking.purchase_id.id @@ -1770,7 +1733,8 @@ class StockPicking(models.Model): 'name': move_line.product_id.name, 'code': move_line.product_id.default_code, 'qty': move_line.qty_done, - 'image': self.env['ir.attachment'].api_image('product.template', 'image_128', move_line.product_id.product_tmpl_id.id), + 'image': self.env['ir.attachment'].api_image('product.template', 'image_128', + move_line.product_id.product_tmpl_id.id), }) response = { @@ -2136,7 +2100,6 @@ class CheckProduct(models.Model): _order = 'picking_id, id' _inherit = ['barcodes.barcode_events_mixin'] - picking_id = fields.Many2one( 'stock.picking', string='Picking Reference', @@ -2589,8 +2552,6 @@ class ScanKoli(models.Model): out_move.qty_done += qty_to_assign qty_koli -= qty_to_assign - - def _reset_qty_done_if_no_scan(self, picking_id): product_bu_pick = self.env['stock.move.line'].search([('picking_id', '=', picking_id)]) -- cgit v1.2.3 From d3fc7f9dfbd3df9687c9531813ac59c3318c6b43 Mon Sep 17 00:00:00 2001 From: Miqdad Date: Mon, 6 Oct 2025 09:08:31 +0700 Subject: rollback --- indoteknik_custom/models/stock_picking.py | 21 +++------------------ 1 file changed, 3 insertions(+), 18 deletions(-) (limited to 'indoteknik_custom/models/stock_picking.py') diff --git a/indoteknik_custom/models/stock_picking.py b/indoteknik_custom/models/stock_picking.py index ae7121da..0b91e79d 100644 --- a/indoteknik_custom/models/stock_picking.py +++ b/indoteknik_custom/models/stock_picking.py @@ -1080,14 +1080,9 @@ class StockPicking(models.Model): return res - def ask_approval(self): if self.env.user.is_accounting: raise UserError("Bisa langsung Validate") - if self.env.user.is_logistic_approver and self.location_id.id == 57 or self.location_id== 57: - raise UserError("Bisa langsung Validate") - - # for calendar distribute only # if self.is_internal_use: @@ -1110,9 +1105,6 @@ class StockPicking(models.Model): if line.qty_done <= 0: raise UserError("Qty tidak boleh 0") pick.approval_status = 'pengajuan1' - if pick.location_id.id == 57: - pick.approval_status = 'pengajuan2' - return def ask_receipt_approval(self): if self.env.user.is_logistic_approver: @@ -1315,9 +1307,6 @@ class StockPicking(models.Model): if self.picking_type_id.code == 'incoming' and self.group_id.id == False and self.is_internal_use == False: raise UserError(_('Tidak bisa Validate jika tidak dari Document SO / PO')) - if self.is_internal_use and not self.env.user.is_logistic_approver and self.location_id.id == 57: - raise UserError("Harus di Approve oleh Logistik") - if self.is_internal_use and not self.env.user.is_accounting: raise UserError("Harus di Approve oleh Accounting") @@ -1344,7 +1333,6 @@ class StockPicking(models.Model): current_time = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S') self.date_reserved = current_time - # Validate Qty Demand Can't higher than Qty Product if self.location_dest_id.id == 58 and 'BU/INPUT/' in self.name: for move in self.move_ids_without_package: @@ -1360,22 +1348,19 @@ class StockPicking(models.Model): ) self.validation_minus_onhand_quantity() - loc = self.location_id - if loc.id == 57 and not self.env.user.is_logistic_approver and self.approval_status in ['pengajuan2']: - raise UserError ("Harus Ask Approval Logistik") self.responsible = self.env.user.id # self.send_koli_to_so() if self.picking_type_code == 'outgoing' and 'BU/OUT/' in self.name: self.check_koli() res = super(StockPicking, self).button_validate() - + # Penambahan link PO di Stock Journal untuk Picking BD for picking in self: if picking.name and 'BD/' in picking.name and picking.purchase_id: stock_journal = self.env['account.move'].search([ ('ref', 'ilike', picking.name + '%'), - ('journal_id', '=', 3) # Stock Journal ID - ], limit = 1) + ('journal_id', '=', 3) # Stock Journal ID + ], limit=1) if stock_journal: stock_journal.write({ 'purchase_order_id': picking.purchase_id.id -- cgit v1.2.3 From 4603578f08af74760c323aac624ea2ae95252d4b Mon Sep 17 00:00:00 2001 From: Miqdad Date: Mon, 6 Oct 2025 11:02:40 +0700 Subject: cr approval BU/IU --- indoteknik_custom/models/stock_picking.py | 57 ++++++++++++++++++++++++++----- 1 file changed, 48 insertions(+), 9 deletions(-) (limited to 'indoteknik_custom/models/stock_picking.py') diff --git a/indoteknik_custom/models/stock_picking.py b/indoteknik_custom/models/stock_picking.py index 43e45c09..8408cdc4 100644 --- a/indoteknik_custom/models/stock_picking.py +++ b/indoteknik_custom/models/stock_picking.py @@ -176,6 +176,28 @@ class StockPicking(models.Model): linked_manual_bu_out = fields.Many2one('stock.picking', string='BU Out', copy=False) area_name = fields.Char(string="Area", compute="_compute_area_name") + is_bu_iu = fields.Boolean('Is BU/IU', compute='_compute_is_bu_iu', default=False, copy=False, readonl=True) + + @api.depends('name') + def _compute_is_bu_iu(self): + for record in self: + if 'BU/IU' in record.name: + record.is_bu_iu = True + else: + record.is_bu_iu = False + + def action_bu_iu_to_pengajuan2(self): + for rec in self: + if not rec.is_bu_iu or not rec.is_internal_use: + raise UserError(_("Tombol ini hanya untuk dokumen BU/IU - Internal Use.")) + if rec.approval_status == False: + raise UserError("Harus Ask Approval terlebih dahulu") + if rec.approval_status in ['pengajuan1'] and self.env.user.is_accounting: + rec.approval_status = 'pengajuan2' + # raise UserError(_("Hanya bisa dijalankan saat status di 'pengajuan1'.")) + rec.message_post(body=_("Status naik ke Approval Logistik oleh %s") % self.env.user.display_name) + + return True # def _get_biteship_api_key(self): # # return self.env['ir.config_parameter'].sudo().get_param('biteship.api_key_test') @@ -343,6 +365,7 @@ class StockPicking(models.Model): except ValueError: return False + def action_get_kgx_pod(self, shipment=False): self.ensure_one() @@ -1063,8 +1086,7 @@ class StockPicking(models.Model): self.sale_id.date_doc_kirim = self.date_doc_kirim def action_assign(self): - if self.env.context.get('default_picking_type_id') and ( - 'BU/INPUT' not in self.name or 'BU/PUT' not in self.name): + if self.env.context.get('default_picking_type_id') and ('BU/INPUT' not in self.name or 'BU/PUT' not in self.name): pickings_to_assign = self.filtered( lambda p: not (p.sale_id and p.sale_id.hold_outgoing) ) @@ -1080,10 +1102,18 @@ class StockPicking(models.Model): return res + def ask_approval(self): - if self.env.user.is_accounting: + # if self.env.user.is_accounting: + # if self.env.user.is_accounting and self.location_id.id == 57 or self.location_id == 57 and self.approval_status in ['pengajuan1', ''] and 'BU/IU' in self.name and self.approval_status == 'pengajuan1': + # raise UserError("Bisa langsung set ke approval logistik") + if self.env.user.is_accounting and self.approval_status == "pengajuan2" and 'BU/IU' in self.name: + raise UserError("Tidak perlu ask approval sudah approval logistik") + if self.env.user.is_logistic_approver and self.location_id.id == 57 or self.location_id== 57 and self.approval_status == 'pengajuan2' and 'BU/IU' in self.name: raise UserError("Bisa langsung Validate") + + # for calendar distribute only # if self.is_internal_use: # stock_move_lines = self.env['stock.move.line'].search([ @@ -1106,6 +1136,7 @@ class StockPicking(models.Model): raise UserError("Qty tidak boleh 0") pick.approval_status = 'pengajuan1' + def ask_receipt_approval(self): if self.env.user.is_logistic_approver: raise UserError('Bisa langsung validate tanpa Ask Receipt') @@ -1307,7 +1338,10 @@ class StockPicking(models.Model): if self.picking_type_id.code == 'incoming' and self.group_id.id == False and self.is_internal_use == False: raise UserError(_('Tidak bisa Validate jika tidak dari Document SO / PO')) - if self.is_internal_use and not self.env.user.is_accounting: + if self.is_internal_use and not self.env.user.is_logistic_approver and self.location_id.id == 57 and self.approval_status == 'pengajuan2': + raise UserError("Harus di Approve oleh Logistik") + + if self.is_internal_use and not self.env.user.is_accounting and self.approval_status == 'pengajuan1' and self.location_id.id == 57: raise UserError("Harus di Approve oleh Accounting") if self.picking_type_id.id == 28 and not self.env.user.is_logistic_approver: @@ -1316,8 +1350,10 @@ class StockPicking(models.Model): 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") - if self.is_internal_use: + if self.is_internal_use and self.approval_status == 'pengajuan2': self.approval_status = 'approved' + elif self.is_internal_use and self.approval_status in ['pengajuan1', '', False]: + raise UserError("Tidak Bisa Validate, set approval status ke approval logistik terlebih dahhulu") elif self.picking_type_id.code == 'incoming': self.approval_receipt_status = 'approved' @@ -1333,6 +1369,7 @@ class StockPicking(models.Model): current_time = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S') self.date_reserved = current_time + # Validate Qty Demand Can't higher than Qty Product if self.location_dest_id.id == 58 and 'BU/INPUT/' in self.name: for move in self.move_ids_without_package: @@ -1359,8 +1396,8 @@ class StockPicking(models.Model): if picking.name and 'BD/' in picking.name and picking.purchase_id: stock_journal = self.env['account.move'].search([ ('ref', 'ilike', picking.name + '%'), - ('journal_id', '=', 3) # Stock Journal ID - ], limit=1) + ('journal_id', '=', 3) # Stock Journal ID + ], limit = 1) if stock_journal: stock_journal.write({ 'purchase_order_id': picking.purchase_id.id @@ -1733,8 +1770,7 @@ class StockPicking(models.Model): 'name': move_line.product_id.name, 'code': move_line.product_id.default_code, 'qty': move_line.qty_done, - 'image': self.env['ir.attachment'].api_image('product.template', 'image_128', - move_line.product_id.product_tmpl_id.id), + 'image': self.env['ir.attachment'].api_image('product.template', 'image_128', move_line.product_id.product_tmpl_id.id), }) response = { @@ -2100,6 +2136,7 @@ class CheckProduct(models.Model): _order = 'picking_id, id' _inherit = ['barcodes.barcode_events_mixin'] + picking_id = fields.Many2one( 'stock.picking', string='Picking Reference', @@ -2552,6 +2589,8 @@ class ScanKoli(models.Model): out_move.qty_done += qty_to_assign qty_koli -= qty_to_assign + + def _reset_qty_done_if_no_scan(self, picking_id): product_bu_pick = self.env['stock.move.line'].search([('picking_id', '=', picking_id)]) -- cgit v1.2.3 From 8fe189d8f4caeed4b1aff764abc005b4e4ab3979 Mon Sep 17 00:00:00 2001 From: Miqdad Date: Mon, 6 Oct 2025 13:59:19 +0700 Subject: change button name and fix wrong validation --- indoteknik_custom/models/stock_picking.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'indoteknik_custom/models/stock_picking.py') diff --git a/indoteknik_custom/models/stock_picking.py b/indoteknik_custom/models/stock_picking.py index 8408cdc4..be0d77ac 100644 --- a/indoteknik_custom/models/stock_picking.py +++ b/indoteknik_custom/models/stock_picking.py @@ -1338,11 +1338,11 @@ class StockPicking(models.Model): if self.picking_type_id.code == 'incoming' and self.group_id.id == False and self.is_internal_use == False: raise UserError(_('Tidak bisa Validate jika tidak dari Document SO / PO')) - if self.is_internal_use and not self.env.user.is_logistic_approver and self.location_id.id == 57 and self.approval_status == 'pengajuan2': - raise UserError("Harus di Approve oleh Logistik") + # if self.is_internal_use and not self.env.user.is_logistic_approver and self.location_id.id == 57 and self.approval_status == 'pengajuan2': + # raise UserError("Harus di Approve oleh Logistik") - if self.is_internal_use and not self.env.user.is_accounting and self.approval_status == 'pengajuan1' and self.location_id.id == 57: - raise UserError("Harus di Approve oleh Accounting") + if self.is_internal_use and not self.env.user.is_logistic_approver and self.approval_status in ['pengajuan1', 'pengajuan2'] and self.location_id.id == 57: + raise UserError("Harus di Approve oleh Logistik") if self.picking_type_id.id == 28 and not self.env.user.is_logistic_approver: raise UserError("Harus di Approve oleh Logistik") -- cgit v1.2.3 From f9645a14ad98a901ae66340b87c592f7a0701d01 Mon Sep 17 00:00:00 2001 From: Miqdad Date: Mon, 6 Oct 2025 14:09:41 +0700 Subject: add more vals --- indoteknik_custom/models/stock_picking.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'indoteknik_custom/models/stock_picking.py') diff --git a/indoteknik_custom/models/stock_picking.py b/indoteknik_custom/models/stock_picking.py index be0d77ac..a9c09ab7 100644 --- a/indoteknik_custom/models/stock_picking.py +++ b/indoteknik_custom/models/stock_picking.py @@ -194,8 +194,9 @@ class StockPicking(models.Model): raise UserError("Harus Ask Approval terlebih dahulu") if rec.approval_status in ['pengajuan1'] and self.env.user.is_accounting: rec.approval_status = 'pengajuan2' - # raise UserError(_("Hanya bisa dijalankan saat status di 'pengajuan1'.")) rec.message_post(body=_("Status naik ke Approval Logistik oleh %s") % self.env.user.display_name) + if rec.approval_status in ['pengajuan1', 'pengajuan2', ''] and not self.env.user.is_accounting: + raise UserError("Tombol hanya untuk accounting") return True -- cgit v1.2.3 From 3c7176c6d87c4a1385e5a87e119878b6e9a5d88f Mon Sep 17 00:00:00 2001 From: Miqdad Date: Tue, 7 Oct 2025 15:08:17 +0700 Subject: add more vals IU approval --- indoteknik_custom/models/stock_picking.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'indoteknik_custom/models/stock_picking.py') diff --git a/indoteknik_custom/models/stock_picking.py b/indoteknik_custom/models/stock_picking.py index a2bd7339..51b6276c 100644 --- a/indoteknik_custom/models/stock_picking.py +++ b/indoteknik_custom/models/stock_picking.py @@ -1340,11 +1340,14 @@ class StockPicking(models.Model): raise UserError(_('Tidak bisa Validate jika tidak dari Document SO / PO')) # if self.is_internal_use and not self.env.user.is_logistic_approver and self.location_id.id == 57 and self.approval_status == 'pengajuan2': - # raise UserError("Harus di Approve oleh Logistik") + # raise UserError("Harus di Approve oleh Logistik") - if self.is_internal_use and not self.env.user.is_logistic_approver and self.approval_status in ['pengajuan1', 'pengajuan2'] and self.location_id.id == 57: + if self.is_internal_use and not self.env.user.is_logistic_approver and self.approval_status in ['pengajuan1', 'pengajuan2'] and self.location_id.id == 57 and self.is_bu_iu == True and 'BU/IU' in self.name: raise UserError("Harus di Approve oleh Logistik") + if self.is_internal_use and not self.env.user.is_accounting and self.approval_status in ['pengajuan1', '', False] and self.is_bu_iu == False: + raise UserError("Harus di Approve oleh Accounting") + if self.picking_type_id.id == 28 and not self.env.user.is_logistic_approver: raise UserError("Harus di Approve oleh Logistik") @@ -1353,7 +1356,7 @@ class StockPicking(models.Model): if self.is_internal_use and self.approval_status == 'pengajuan2': self.approval_status = 'approved' - elif self.is_internal_use and self.approval_status in ['pengajuan1', '', False]: + elif self.is_internal_use and self.approval_status in ['pengajuan1', '', False] and 'BU/IU' in self.name and self.is_bu_iu == True: raise UserError("Tidak Bisa Validate, set approval status ke approval logistik terlebih dahhulu") elif self.picking_type_id.code == 'incoming': self.approval_receipt_status = 'approved' -- cgit v1.2.3 From 92d28be458ca53c9994a175225232b24c7fde283 Mon Sep 17 00:00:00 2001 From: Miqdad Date: Tue, 7 Oct 2025 15:20:29 +0700 Subject: fix approval IU --- indoteknik_custom/models/stock_picking.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'indoteknik_custom/models/stock_picking.py') diff --git a/indoteknik_custom/models/stock_picking.py b/indoteknik_custom/models/stock_picking.py index 51b6276c..4772c433 100644 --- a/indoteknik_custom/models/stock_picking.py +++ b/indoteknik_custom/models/stock_picking.py @@ -1342,7 +1342,10 @@ class StockPicking(models.Model): # if self.is_internal_use and not self.env.user.is_logistic_approver and self.location_id.id == 57 and self.approval_status == 'pengajuan2': # raise UserError("Harus di Approve oleh Logistik") - if self.is_internal_use and not self.env.user.is_logistic_approver and self.approval_status in ['pengajuan1', 'pengajuan2'] and self.location_id.id == 57 and self.is_bu_iu == True and 'BU/IU' in self.name: + if self.is_internal_use and self.approval_status in ['pengajuan1', '', False] and 'BU/IU' in self.name and self.is_bu_iu == True: + raise UserError("Tidak Bisa Validate, set approval status ke approval logistik terlebih dahhulu") + + if self.is_internal_use and not self.env.user.is_logistic_approver and self.approval_status in ['pengajuan2'] and self.is_bu_iu == True and 'BU/IU' in self.name: raise UserError("Harus di Approve oleh Logistik") if self.is_internal_use and not self.env.user.is_accounting and self.approval_status in ['pengajuan1', '', False] and self.is_bu_iu == False: @@ -1356,8 +1359,6 @@ class StockPicking(models.Model): if self.is_internal_use and self.approval_status == 'pengajuan2': self.approval_status = 'approved' - elif self.is_internal_use and self.approval_status in ['pengajuan1', '', False] and 'BU/IU' in self.name and self.is_bu_iu == True: - raise UserError("Tidak Bisa Validate, set approval status ke approval logistik terlebih dahhulu") elif self.picking_type_id.code == 'incoming': self.approval_receipt_status = 'approved' -- cgit v1.2.3 From d72c8fb9cd97552ef15aee0b70f7e1248b4c4696 Mon Sep 17 00:00:00 2001 From: Miqdad Date: Wed, 8 Oct 2025 10:00:56 +0700 Subject: constrain delivery departure date to denise and faishal --- indoteknik_custom/models/stock_picking.py | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'indoteknik_custom/models/stock_picking.py') diff --git a/indoteknik_custom/models/stock_picking.py b/indoteknik_custom/models/stock_picking.py index 4772c433..217e76cb 100644 --- a/indoteknik_custom/models/stock_picking.py +++ b/indoteknik_custom/models/stock_picking.py @@ -178,6 +178,14 @@ class StockPicking(models.Model): area_name = fields.Char(string="Area", compute="_compute_area_name") is_bu_iu = fields.Boolean('Is BU/IU', compute='_compute_is_bu_iu', default=False, copy=False, readonl=True) + @api.constrains('driver_departure_date') + def _constrains_driver_departure_date(self): + allowed_user_ids = [17, 6277, 25] + for record in self: + if record.driver_departure_date and self.env.user.id not in allowed_user_ids: + raise UserError("Hanya Denise dan Faishal yang dapat mengubah Delivery Departure Date.") + + @api.depends('name') def _compute_is_bu_iu(self): for record in self: -- cgit v1.2.3 From f71f148d00b546bc46922eeeeaa512f79cecd573 Mon Sep 17 00:00:00 2001 From: Miqdad Date: Wed, 8 Oct 2025 15:04:22 +0700 Subject: balikin sp --- indoteknik_custom/models/stock_picking.py | 8 -------- 1 file changed, 8 deletions(-) (limited to 'indoteknik_custom/models/stock_picking.py') diff --git a/indoteknik_custom/models/stock_picking.py b/indoteknik_custom/models/stock_picking.py index 217e76cb..4772c433 100644 --- a/indoteknik_custom/models/stock_picking.py +++ b/indoteknik_custom/models/stock_picking.py @@ -178,14 +178,6 @@ class StockPicking(models.Model): area_name = fields.Char(string="Area", compute="_compute_area_name") is_bu_iu = fields.Boolean('Is BU/IU', compute='_compute_is_bu_iu', default=False, copy=False, readonl=True) - @api.constrains('driver_departure_date') - def _constrains_driver_departure_date(self): - allowed_user_ids = [17, 6277, 25] - for record in self: - if record.driver_departure_date and self.env.user.id not in allowed_user_ids: - raise UserError("Hanya Denise dan Faishal yang dapat mengubah Delivery Departure Date.") - - @api.depends('name') def _compute_is_bu_iu(self): for record in self: -- cgit v1.2.3 From c8b3d4f3c5da81eb3858af6b8a7fc54b83a286a5 Mon Sep 17 00:00:00 2001 From: Miqdad Date: Wed, 8 Oct 2025 15:20:43 +0700 Subject: delivery departure date val --- indoteknik_custom/models/stock_picking.py | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'indoteknik_custom/models/stock_picking.py') diff --git a/indoteknik_custom/models/stock_picking.py b/indoteknik_custom/models/stock_picking.py index 4772c433..8e947267 100644 --- a/indoteknik_custom/models/stock_picking.py +++ b/indoteknik_custom/models/stock_picking.py @@ -1654,6 +1654,11 @@ class StockPicking(models.Model): line.sale_line_id = sale_line.id def write(self, vals): + allowed_user_ids = [17, 6277] + if 'driver_departure_date' in vals: + if self.env.user.id not in allowed_user_ids and not self.env.context.get('allow_driver_departure_edit'): + raise UserError("Hanya Denise dan Faisal yang dapat mengubah Delivery Departure Date.") + if 'linked_manual_bu_out' in vals: for record in self: if (record.picking_type_code == 'internal' -- cgit v1.2.3 From 393958c36bf49b7b2dbd888b81c345b7734151a0 Mon Sep 17 00:00:00 2001 From: Miqdad Date: Thu, 9 Oct 2025 11:35:17 +0700 Subject: balikin del dep date --- indoteknik_custom/models/stock_picking.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'indoteknik_custom/models/stock_picking.py') diff --git a/indoteknik_custom/models/stock_picking.py b/indoteknik_custom/models/stock_picking.py index 8e947267..87182277 100644 --- a/indoteknik_custom/models/stock_picking.py +++ b/indoteknik_custom/models/stock_picking.py @@ -1654,10 +1654,10 @@ class StockPicking(models.Model): line.sale_line_id = sale_line.id def write(self, vals): - allowed_user_ids = [17, 6277] - if 'driver_departure_date' in vals: - if self.env.user.id not in allowed_user_ids and not self.env.context.get('allow_driver_departure_edit'): - raise UserError("Hanya Denise dan Faisal yang dapat mengubah Delivery Departure Date.") + # allowed_user_ids = [17, 6277] + # if 'driver_departure_date' in vals: + # if self.env.user.id not in allowed_user_ids and not self.env.context.get('allow_driver_departure_edit'): + # raise UserError("Hanya Denise dan Faisal yang dapat mengubah Delivery Departure Date.") if 'linked_manual_bu_out' in vals: for record in self: -- cgit v1.2.3 From b25d39b4d5dd456ef2e40a25ce3608e5c9b6694d Mon Sep 17 00:00:00 2001 From: Miqdad Date: Thu, 9 Oct 2025 14:55:00 +0700 Subject: fix delivery departure date validation --- indoteknik_custom/models/stock_picking.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'indoteknik_custom/models/stock_picking.py') diff --git a/indoteknik_custom/models/stock_picking.py b/indoteknik_custom/models/stock_picking.py index 87182277..8a5888fc 100644 --- a/indoteknik_custom/models/stock_picking.py +++ b/indoteknik_custom/models/stock_picking.py @@ -471,9 +471,9 @@ class StockPicking(models.Model): if len(picking.scan_koli_lines) > 0: if len(picking.scan_koli_lines) != picking.total_mapping_koli: raise UserError("Scan Koli Tidak Sesuai Dengan Total Mapping Koli") - - picking.driver_departure_date = now - + picking.with_context(allow_driver_departure_edit=True).write({ + 'driver_departure_date': now + }) @api.depends('total_so_koli') def _compute_total_so_koli(self): for picking in self: @@ -1654,10 +1654,10 @@ class StockPicking(models.Model): line.sale_line_id = sale_line.id def write(self, vals): - # allowed_user_ids = [17, 6277] - # if 'driver_departure_date' in vals: - # if self.env.user.id not in allowed_user_ids and not self.env.context.get('allow_driver_departure_edit'): - # raise UserError("Hanya Denise dan Faisal yang dapat mengubah Delivery Departure Date.") + allowed_user_ids = [17, 6277] + if 'driver_departure_date' in vals: + if self.env.user.id not in allowed_user_ids and not self.env.context.get('allow_driver_departure_edit'): + raise UserError("Hanya Denise dan Faisal yang dapat mengubah Delivery Departure Date.") if 'linked_manual_bu_out' in vals: for record in self: -- cgit v1.2.3 From e4b191155bf44bfcd58d6ae1b95d4a112bd43547 Mon Sep 17 00:00:00 2001 From: Miqdad Date: Fri, 10 Oct 2025 11:17:41 +0700 Subject: balikin driver dep date --- indoteknik_custom/models/stock_picking.py | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) (limited to 'indoteknik_custom/models/stock_picking.py') diff --git a/indoteknik_custom/models/stock_picking.py b/indoteknik_custom/models/stock_picking.py index 8a5888fc..4772c433 100644 --- a/indoteknik_custom/models/stock_picking.py +++ b/indoteknik_custom/models/stock_picking.py @@ -471,9 +471,9 @@ class StockPicking(models.Model): if len(picking.scan_koli_lines) > 0: if len(picking.scan_koli_lines) != picking.total_mapping_koli: raise UserError("Scan Koli Tidak Sesuai Dengan Total Mapping Koli") - picking.with_context(allow_driver_departure_edit=True).write({ - 'driver_departure_date': now - }) + + picking.driver_departure_date = now + @api.depends('total_so_koli') def _compute_total_so_koli(self): for picking in self: @@ -1654,11 +1654,6 @@ class StockPicking(models.Model): line.sale_line_id = sale_line.id def write(self, vals): - allowed_user_ids = [17, 6277] - if 'driver_departure_date' in vals: - if self.env.user.id not in allowed_user_ids and not self.env.context.get('allow_driver_departure_edit'): - raise UserError("Hanya Denise dan Faisal yang dapat mengubah Delivery Departure Date.") - if 'linked_manual_bu_out' in vals: for record in self: if (record.picking_type_code == 'internal' -- cgit v1.2.3