From af127b94e7b597a3451f42199df56e27899272fd Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Tue, 27 May 2025 10:45:11 +0700 Subject: push --- indoteknik_custom/models/stock_picking.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indoteknik_custom/models/stock_picking.py b/indoteknik_custom/models/stock_picking.py index 05f946fd..887b2f92 100644 --- a/indoteknik_custom/models/stock_picking.py +++ b/indoteknik_custom/models/stock_picking.py @@ -625,7 +625,7 @@ class StockPicking(models.Model): ('state', '=', 'done'), ('carrier_id', '=', 151) ]) - for picking in pickings: + for picking in self: if not picking.name: raise UserError("Name pada stock.picking tidak ditemukan.") -- cgit v1.2.3 From 755f6efe380cbbdd05ba592f651ca87030a22143 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Tue, 27 May 2025 10:57:24 +0700 Subject: fix api shipment group --- indoteknik_custom/models/purchase_order.py | 4 ++-- indoteknik_custom/models/shipment_group.py | 10 ++++++---- indoteknik_custom/models/stock_picking.py | 4 ++-- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/indoteknik_custom/models/purchase_order.py b/indoteknik_custom/models/purchase_order.py index 36c4c7b9..2513f8fd 100755 --- a/indoteknik_custom/models/purchase_order.py +++ b/indoteknik_custom/models/purchase_order.py @@ -849,8 +849,8 @@ class PurchaseOrder(models.Model): ) if not self.from_apo: - if not self.matches_so and not self.env.user.has_group('indoteknik_custom.group_role_merchandiser') and not self.env.user.is_leader: - raise UserError("Tidak ada link dengan SO, harus approval Merchandise") + if not self.matches_so and not self.env.user.id == 21: + raise UserError("Tidak ada link dengan SO, harus approval Rafly") send_email = False if not self.not_update_purchasepricelist: diff --git a/indoteknik_custom/models/shipment_group.py b/indoteknik_custom/models/shipment_group.py index 2d84d54c..ea91238a 100644 --- a/indoteknik_custom/models/shipment_group.py +++ b/indoteknik_custom/models/shipment_group.py @@ -19,11 +19,13 @@ class ShipmentGroup(models.Model): def sync_api_shipping(self): for rec in self.shipment_line: + picking_names = [picking.name for picking in rec.picking_id] if rec.shipment_id.carrier_id.id == 173: - rec.picking_id.action_get_kgx_pod() - - if rec.shipment_id.carrier_id.id == 151: - rec.picking_id.track_envio_shipment() + rec.picking_id.action_get_kgx_pod( + shipment=f"{self.number},{','.join(picking_names)}" + ) + elif rec.shipment_id.carrier_id.id == 151: + rec.picking_id.track_envio_shipment() @api.depends('shipment_line.total_colly') def _compute_total_colly_line(self): diff --git a/indoteknik_custom/models/stock_picking.py b/indoteknik_custom/models/stock_picking.py index 887b2f92..3223377c 100644 --- a/indoteknik_custom/models/stock_picking.py +++ b/indoteknik_custom/models/stock_picking.py @@ -310,10 +310,10 @@ class StockPicking(models.Model): except ValueError: return False - def action_get_kgx_pod(self): + def action_get_kgx_pod(self, shipment=False): self.ensure_one() - awb_number = self._get_kgx_awb_number() + awb_number = shipment or self._get_kgx_awb_number() if not awb_number: raise UserError("Nomor AWB tidak dapat dibuat, pastikan picking memiliki name dan origin") -- cgit v1.2.3 From 660d79ee317460e79a61287bda7d7a8e8b423b48 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Tue, 27 May 2025 11:00:46 +0700 Subject: push --- indoteknik_custom/models/purchase_order.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/indoteknik_custom/models/purchase_order.py b/indoteknik_custom/models/purchase_order.py index 2513f8fd..53037703 100755 --- a/indoteknik_custom/models/purchase_order.py +++ b/indoteknik_custom/models/purchase_order.py @@ -808,8 +808,8 @@ class PurchaseOrder(models.Model): # test = line.product_uom_qty # test2 = line.product_id.plafon_qty # test3 = test2 + line.product_uom_qty - if line.product_uom_qty > line.product_id.plafon_qty + line.product_uom_qty and not self.env.user.has_group('indoteknik_custom.group_role_merchandiser'): - raise UserError('Product '+line.product_id.name+' melebihi plafon, harus Approval MD') + if line.product_uom_qty > line.product_id.plafon_qty + line.product_uom_qty and not self.env.user.id == 21: + raise UserError('Product '+line.product_id.name+' melebihi plafon, harus Approval Rafly') def check_different_vendor_so_po(self): vendor_po = self.partner_id.id -- cgit v1.2.3 From 4ba7242388db36fa641ea2008af08319a3dc014c Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Tue, 27 May 2025 11:03:53 +0700 Subject: fix syntax get name picking --- indoteknik_custom/models/shipment_group.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indoteknik_custom/models/shipment_group.py b/indoteknik_custom/models/shipment_group.py index ea91238a..09a4fba9 100644 --- a/indoteknik_custom/models/shipment_group.py +++ b/indoteknik_custom/models/shipment_group.py @@ -19,7 +19,7 @@ class ShipmentGroup(models.Model): def sync_api_shipping(self): for rec in self.shipment_line: - picking_names = [picking.name for picking in rec.picking_id] + picking_names = [picking.picking_id.name for picking in rec] if rec.shipment_id.carrier_id.id == 173: rec.picking_id.action_get_kgx_pod( shipment=f"{self.number},{','.join(picking_names)}" -- cgit v1.2.3 From dad6bca8abdda9e5987a0adb8cae75540b6176eb Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Tue, 27 May 2025 11:10:09 +0700 Subject: push --- indoteknik_custom/models/shipment_group.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/indoteknik_custom/models/shipment_group.py b/indoteknik_custom/models/shipment_group.py index 09a4fba9..9ebf36c0 100644 --- a/indoteknik_custom/models/shipment_group.py +++ b/indoteknik_custom/models/shipment_group.py @@ -19,10 +19,10 @@ class ShipmentGroup(models.Model): def sync_api_shipping(self): for rec in self.shipment_line: - picking_names = [picking.picking_id.name for picking in rec] + picking_names = [lines.picking_id.name for lines in self.shipment_line] if rec.shipment_id.carrier_id.id == 173: rec.picking_id.action_get_kgx_pod( - shipment=f"{self.number},{','.join(picking_names)}" + shipment=f"{self.number}, {', '.join(picking_names)}" ) elif rec.shipment_id.carrier_id.id == 151: rec.picking_id.track_envio_shipment() -- cgit v1.2.3 From ae9766498d304a8336737453310e4272929cea73 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Tue, 27 May 2025 11:20:09 +0700 Subject: push --- indoteknik_custom/models/shipment_group.py | 2 +- indoteknik_custom/models/stock_picking.py | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/indoteknik_custom/models/shipment_group.py b/indoteknik_custom/models/shipment_group.py index 9ebf36c0..fcde39c9 100644 --- a/indoteknik_custom/models/shipment_group.py +++ b/indoteknik_custom/models/shipment_group.py @@ -25,7 +25,7 @@ class ShipmentGroup(models.Model): shipment=f"{self.number}, {', '.join(picking_names)}" ) elif rec.shipment_id.carrier_id.id == 151: - rec.picking_id.track_envio_shipment() + rec.picking_id.track_envio_shipment(shipment=f"{self.number}") @api.depends('shipment_line.total_colly') def _compute_total_colly_line(self): diff --git a/indoteknik_custom/models/stock_picking.py b/indoteknik_custom/models/stock_picking.py index 3223377c..ea52450e 100644 --- a/indoteknik_custom/models/stock_picking.py +++ b/indoteknik_custom/models/stock_picking.py @@ -619,18 +619,19 @@ class StockPicking(models.Model): except ValueError: raise UserError(f"Format waktu tidak sesuai: {date_str}") - def track_envio_shipment(self): + def track_envio_shipment(self, shipment=False): pickings = self.env['stock.picking'].search([ ('picking_type_code', '=', 'outgoing'), ('state', '=', 'done'), ('carrier_id', '=', 151) ]) for picking in self: + name = shipment or picking.name if not picking.name: raise UserError("Name pada stock.picking tidak ditemukan.") # API URL dan headers - url = f"https://api.envio.co.id/v1/tracking/distribution?code={picking.name}" + url = f"https://api.envio.co.id/v1/tracking/distribution?code={name}" headers = { 'Authorization': 'Bearer JZ0Seh6qpYJAC3CJHdhF7sPqv8B/uSSfZe1VX5BL?vPYdo', 'Content-Type': 'application/json', -- cgit v1.2.3