summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAzka Nathan <darizkyfaz@gmail.com>2025-07-02 09:19:00 +0700
committerAzka Nathan <darizkyfaz@gmail.com>2025-07-02 09:19:00 +0700
commit9c17104f86f116782f0ed36f82d7c3de7130d363 (patch)
tree2dfc7d93ac0df5966403724aa5b1283e70f89ebe
parent32e30884a8897bb553be55fae826961af1b970a6 (diff)
preview pdf resi
-rwxr-xr-xfixco_custom/models/detail_order.py2
-rwxr-xr-xfixco_custom/models/stock_picking.py16
-rw-r--r--fixco_custom/views/report_picking_list.xml2
-rwxr-xr-xfixco_custom/views/stock_picking.xml1
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 @@
<t t-call="web.external_layout">
<div class="page" style="font-family: Arial, sans-serif; max-width: 800px; margin: 0 auto;">
<!-- Barcode Header -->
- <div style="text-align: right; margin-bottom: -110px;">
+ <div style="text-align: right; margin-bottom: -90px;">
<img t-att-src="'/report/barcode/?type=%s&amp;value=%s&amp;width=%s&amp;height=%s' % ('QR', o.invoice_mp, 100, 100)"
style="width:100px;height:100px;" alt="QR Code"/>
</div>
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 @@
<field name="invoice_number" readonly="1"/>
<field name="invoice_mp" readonly="1"/>
<field name="pdf_label_url" readonly="1" widget="url"/>
+ <field name="pdf_label_preview" widget="pdf_viewer"/>
</group>
</group>