From 06cfdbaab8d7620c03aab75433a9c83ce068166d Mon Sep 17 00:00:00 2001 From: Nicolas Martinelli Date: Thu, 7 Feb 2019 10:01:51 +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. opw-1937858 closes odoo/odoo#30912 --- odoo/addons/base/models/ir_actions_report.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/odoo/addons/base/models/ir_actions_report.py b/odoo/addons/base/models/ir_actions_report.py index 027f2abd29b..c33a408ae61 100644 --- a/odoo/addons/base/models/ir_actions_report.py +++ b/odoo/addons/base/models/ir_actions_report.py @@ -467,7 +467,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):