summaryrefslogtreecommitdiff
path: root/fixco_custom/models/stock_picking.py
diff options
context:
space:
mode:
Diffstat (limited to 'fixco_custom/models/stock_picking.py')
-rwxr-xr-xfixco_custom/models/stock_picking.py16
1 files changed, 16 insertions, 0 deletions
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):