From 9c17104f86f116782f0ed36f82d7c3de7130d363 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Wed, 2 Jul 2025 09:19:00 +0700 Subject: preview pdf resi --- fixco_custom/models/detail_order.py | 2 +- fixco_custom/models/stock_picking.py | 16 ++++++++++++++++ fixco_custom/views/report_picking_list.xml | 2 +- fixco_custom/views/stock_picking.xml | 1 + 4 files changed, 19 insertions(+), 2 deletions(-) diff --git a/fixco_custom/models/detail_order.py b/fixco_custom/models/detail_order.py index f5596d7..74608b4 100755 --- a/fixco_custom/models/detail_order.py +++ b/fixco_custom/models/detail_order.py @@ -226,7 +226,7 @@ class DetailOrder(models.Model): bline.variant_id, price_bundling_bottom, price, - actual_price=combined_item['actualPrice']/combined_item['quantity'] # Use average price + actual_price=combined_item['actualPrice'] ) order_lines.append((0, 0, { 'product_id': bline.variant_id.id if bline.variant_id else product.id, diff --git a/fixco_custom/models/stock_picking.py b/fixco_custom/models/stock_picking.py index 9636956..3beff4a 100755 --- a/fixco_custom/models/stock_picking.py +++ b/fixco_custom/models/stock_picking.py @@ -38,6 +38,22 @@ class StockPicking(models.Model): note_by_buyer = fields.Char('Note By Buyer') carrier = fields.Char(string='Shipping Method') shipment_group_id = fields.Many2one('shipment.group', string='Shipment Group', copy=False) + pdf_label_preview = fields.Binary( + string="PDF Preview", + compute="_compute_pdf_binary", + store=False + ) + + def _compute_pdf_binary(self): + for record in self: + record.pdf_label_preview = False + if record.pdf_label_url: + try: + response = requests.get(record.pdf_label_url, timeout=10) + if response.status_code == 200 and response.headers.get('Content-Type') == 'application/pdf': + record.pdf_label_preview = base64.b64encode(response.content) + except Exception as e: + _logger.warning(f"Gagal mengambil PDF dari URL: {e}") @api.constrains('sale_id') def _check_sale_order(self): diff --git a/fixco_custom/views/report_picking_list.xml b/fixco_custom/views/report_picking_list.xml index 1b4ffbe..109a780 100644 --- a/fixco_custom/views/report_picking_list.xml +++ b/fixco_custom/views/report_picking_list.xml @@ -18,7 +18,7 @@
-
+
QR Code
diff --git a/fixco_custom/views/stock_picking.xml b/fixco_custom/views/stock_picking.xml index 21d0aae..e8aee28 100755 --- a/fixco_custom/views/stock_picking.xml +++ b/fixco_custom/views/stock_picking.xml @@ -32,6 +32,7 @@ + -- cgit v1.2.3