From 6ebbea16817fa194f2d084c3a8821d21e88dc483 Mon Sep 17 00:00:00 2001 From: "Lucas Perais (lpe)" Date: Fri, 6 Sep 2019 07:56:48 +0000 Subject: [PATCH] [FIX] base: barcode qweb field correct API Before this commit, the barcode Qweb Field had a option called "type", which meant what is the mapping between numbers and barcode, that mapping is called a symbology https://www.barcoding.com/resources/barcoding-basics/barcode-symbologies/ This option "type" collided with what the qweb engine does at ``` qweb > _compile_directive_field that calls ir_qweb > _get_field ``` It resulted in a crash where type = "barcode" was not a valid symbology to pass to the barcode lib It is safe to say that this barcode widget was never user, otherwise it would have crashed This commit changes that non-functioning API, and the barcode renders well OPW 2066870 forward-port of #36499 (330d862513dba5bbc4716fe9c8694fd0db696934) closes odoo/odoo#36499 closes odoo/odoo#36658 Signed-off-by: Lucas Perais (lpe) Signed-off-by: Lucas Perais (lpe) --- odoo/addons/base/i18n/base.pot | 6 ++++++ odoo/addons/base/models/ir_qweb_fields.py | 6 +++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/odoo/addons/base/i18n/base.pot b/odoo/addons/base/i18n/base.pot index f23d932a1ac..c4cb51ebe6d 100644 --- a/odoo/addons/base/i18n/base.pot +++ b/odoo/addons/base/i18n/base.pot @@ -6938,6 +6938,12 @@ msgstr "" #. module: base #: code:addons/base/models/ir_qweb_fields.py:610 #, python-format +msgid "Barcode symbology" +msgstr "" + +#. module: base +#: code:addons/base/models/ir_qweb_fields.py:603 +#, python-format msgid "Barcode type" msgstr "" diff --git a/odoo/addons/base/models/ir_qweb_fields.py b/odoo/addons/base/models/ir_qweb_fields.py index 097ba57e69d..046e98e357b 100644 --- a/odoo/addons/base/models/ir_qweb_fields.py +++ b/odoo/addons/base/models/ir_qweb_fields.py @@ -607,7 +607,7 @@ class BarcodeConverter(models.AbstractModel): def get_available_options(self): options = super(BarcodeConverter, self).get_available_options() options.update( - type=dict(type='string', string=_('Barcode type'), description=_('Barcode type, eg: UPCA, EAN13, Code128'), default_value='Code128'), + symbology=dict(type='string', string=_('Barcode symbology'), description=_('Barcode type, eg: UPCA, EAN13, Code128'), default_value='Code128'), width=dict(type='integer', string=_('Width'), default_value=600), height=dict(type='integer', string=_('Height'), default_value=100), humanreadable=dict(type='integer', string=_('Human Readable'), default_value=0), @@ -616,9 +616,9 @@ class BarcodeConverter(models.AbstractModel): @api.model def value_to_html(self, value, options=None): - barcode_type = options.get('type', 'Code128') + barcode_symbology = options.get('symbology', 'Code128') barcode = self.env['ir.actions.report'].barcode( - barcode_type, + barcode_symbology, value, **{key: value for key, value in options.items() if key in ['width', 'height', 'humanreadable']}) return u'' % base64.b64encode(barcode).decode('ascii')