[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 06cfdbaab8
opw-1981988

closes odoo/odoo#33240

Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
This commit is contained in:
Nicolas Martinelli
2019-05-08 09:02:45 +00:00
parent f89d2f3599
commit 6ff5498fc0
+4 -1
View File
@@ -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):