[FIX] translate: get class attribute safely

58d3b670221b3 was not correctly forward ported, it misses the `''` fallback part
of the original commit dc20ab9c02

Without this, traceback is shown.
Step to reproduce:
 - Open HTML Editor (or edit a backend view)
 - Add an input with no class but a value attribute (no type or type text)

closes odoo/odoo#73057

Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
This commit is contained in:
Romain Derie
2021-07-01 09:27:20 +00:00
parent bac1f99312
commit 3ea17f597b
+1 -1
View File
@@ -152,7 +152,7 @@ TRANSLATED_ATTRS = dict.fromkeys({
'value_label',
}, lambda e: True)
TRANSLATED_ATTRS.update(
value=lambda e: (e.tag == 'input' and e.attrib.get('type', 'text') == 'text') and 'datetimepicker-input' not in e.attrib.get('class').split(' '),
value=lambda e: (e.tag == 'input' and e.attrib.get('type', 'text') == 'text') and 'datetimepicker-input' not in e.attrib.get('class', '').split(' '),
text=lambda e: (e.tag == 'field' and e.attrib.get('widget', '') == 'url'),
**{f't-attf-{attr}': cond for attr, cond in TRANSLATED_ATTRS.items()},
)