odoo.tools.view_validation: Invalid XML: A simili button must be tagged with "role='button'".
@validate('calendar', 'diagram', 'form', 'graph', 'kanban', 'pivot', 'search', 'tree', 'activity')
def valid_simili_button(arch, **kwargs):
"""A simili button must be tagged with "role='button'"."""
# Select elements with class 'btn'
xpath = '//a[contains(concat(" ", @class), " btn")'
xpath += ' or contains(concat(" ", @t-att-class), " btn")'
xpath += ' or contains(concat(" ", @t-attf-class), " btn")]'
xpath += '[not(@role="button")]'
if arch.xpath(xpath):
return "Warning"
return True
在calendar、kanban、diagram 等视图上,使用使用a标签的时候 需要加上 role="button"
在odoo 的视图上使用标签,且标签作为按钮使用时,加上 role="button"