From 6ff5498fc079f713519acaa8bde9d916491f379d Mon Sep 17 00:00:00 2001 From: Nicolas Martinelli Date: Wed, 8 May 2019 09:02:45 +0000 Subject: [PATCH] [FIX] base: barcode fallback - Set a product barcode to a 8 letters value, e.g. 'AAAAAAAA' - Print 'Product Barcode (PDF)' (or any other report containing the barcode) The barcode doesn't print. All templates assume that: - a 13 characters barcode is EAN13 - a 8 characters barcode is EAN8 But this assumption is too restrictive: one could want to generate barcodes with such length without following the EAN13 or EAN8 structure. We fall back on Code128 when the barcode generation fails. Backport of 06cfdbaab8d7620c03aab75433a9c83ce068166d opw-1981988 closes odoo/odoo#33240 Signed-off-by: Nicolas Martinelli (nim) --- odoo/addons/base/ir/ir_actions_report.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/odoo/addons/base/ir/ir_actions_report.py b/odoo/addons/base/ir/ir_actions_report.py index 4645eb9a31c..7f2780a2ddb 100644 --- a/odoo/addons/base/ir/ir_actions_report.py +++ b/odoo/addons/base/ir/ir_actions_report.py @@ -444,7 +444,10 @@ class IrActionsReport(models.Model): ) return barcode.asString('png') except (ValueError, AttributeError): - raise ValueError("Cannot convert into barcode.") + if barcode_type == 'Code128': + raise ValueError("Cannot convert into barcode.") + else: + return self.barcode('Code128', value, width=width, height=height, humanreadable=humanreadable) @api.multi def render_template(self, template, values=None):