[FW][FIX] translate: get class attribute safely

The 'class' attribute was not safely accessed using get. Since this attribute is not always
present the condition evaluation failed in some cases.

task-2276724

closes odoo/odoo#72894

X-original-commit: 58d3b670221b37c5c4c67ee53fbc545f6fb70395
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
This commit is contained in:
Sébastien Mottet (oms)
2021-06-29 07:18:50 +00:00
committed by Thibault Delavallée
parent 0249f87ed0
commit dc20ab9c02
+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['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()},
)