[FIX] *: avoid translating CSS classes values

*: project, survey, test_website, website_event, website_sale

This commit fixes all found occurrences of such a case:
```
<t t-set="classes">some_classes</t>
```
=> CSS classes being marked for translation by mistake.

A breaking case was found via task-3636009, where the arabic language
has a translated class on some element which makes some JS crash
because of it.
Steps to reproduce (only for 17.0):
- Create a website with the "Arabic" language as the default language
- Go to the shop page in Arabic
- If you are in grid view, click on the "switch to list view" button and
  if you are in list view, click on the "switch to grid view" button
=> Crash

Note that commit [1] already did something similar a while ago (but
more generically than this commit). In this commit here, broken
occurrences were found using this regex:
```
<t\s+t-set=["']\w+lass(es)?["']\s*>
```

[1]: https://github.com/odoo/odoo/commit/98678199a32b3ba9af999f76980a6110546ec0fc

task-3636009

closes odoo/odoo#147688

X-original-commit: 01b223e3043a3d847fd7dbf8997edcee62c3254a
Related: odoo/enterprise#53463
Signed-off-by: Romain Derie (rde) <rde@odoo.com>
Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
This commit is contained in:
qsm-odoo
2024-01-04 22:03:50 +00:00
parent 0f0d2baa18
commit c96760a76b
5 changed files with 7 additions and 7 deletions
@@ -219,7 +219,7 @@
<div class="col-12 col-md-9">
<div class="d-flex align-items-center gap-2">
<t t-call="project.portal_my_tasks_priority_widget_template">
<t t-set="classes">fs-4</t>
<t t-set="classes" t-translation="off">fs-4</t>
</t>
<h3 t-field="task.name" class="text-truncate my-0"/>
<small class="text-muted d-none d-md-inline align-self-end">(#<span t-field="task.id"/>)</small>
@@ -159,7 +159,7 @@
<nav class="navbar navbar-light rounded">
<div t-if="question_and_page_data" class="justify-content-between w-100">
<ul class="nav o_survey_results_topbar_dropdown_filters">
<t t-set="dropdown_item_classes">dropdown-item d-flex align-items-center justify-content-between</t>
<t t-set="dropdown_item_classes" t-translation="off">dropdown-item d-flex align-items-center justify-content-between</t>
<li class="nav-item dropdown me-2 my-1">
<a href="#" role="button" data-bs-toggle="dropdown"
t-attf-class="btn btn-outline-primary dropdown-toggle #{'active' if search_finished else ''}">
@@ -25,7 +25,7 @@ class TestWebsiteControllerPage(HttpCase):
"type": "qweb",
"model": cls.model.model,
"arch": """<t t-call="website.layout">
<t t-set="_activeClasses">border-primary</t>
<t t-set="_activeClasses" t-translation="off">border-primary</t>
<div t-attf-class="listing_layout_switcher btn-group ms-3" t-att-data-active-classes="_activeClasses" t-att-data-view-id="view_id">
<input type="radio" class="btn-check" name="wstudio_layout" id="o_wstudio_apply_grid" value="grid" t-att-checked="'checked' if layout_mode != 'list' else None"/>
<label t-attf-class="btn btn-light #{_activeClasses if layout_mode != 'list' else None} o_wstudio_apply_grid" title="Grid" for="o_wstudio_apply_grid">
@@ -132,7 +132,7 @@
<div class="d-flex flex-wrap justify-content-between align-items-center w-100 mb-3">
<h4 class="mb-0">Tickets</h4>
<t t-call="website_event.registration_configure_tickets_button" t-if="request.env.user.has_group('event.group_event_manager')">
<t t-set="linkClasses">ms-2</t>
<t t-set="linkClasses" t-translation="off">ms-2</t>
</t>
</div>
<button t-if="event.event_registrations_open" type="button" data-bs-toggle="modal" data-bs-target="#modal_ticket_registration" class="btn btn-primary w-100">Register</button>
@@ -149,7 +149,7 @@
</em>
<t t-call="website_event.registration_configure_tickets_button"
t-if="request.env.user.has_group('event.group_event_manager')">
<t t-set="linkClasses">alert-link my-3</t>
<t t-set="linkClasses" t-translation="off">alert-link my-3</t>
</t>
</div>
<button class="btn btn-danger" disabled="1">Registrations not yet open</button>
+2 -2
View File
@@ -500,7 +500,7 @@
</template>
<template id="website_sale.add_grid_or_list_option" active="True" name="Grid or List button">
<t t-set="_activeClasses">active</t>
<t t-set="_activeClasses" t-translation="off">active</t>
<div t-attf-class="o_wsale_apply_layout btn-group {{_classes}}" t-att-data-active-classes="_activeClasses">
<input type="radio" class="btn-check" name="wsale_products_layout" id="o_wsale_apply_grid" t-att-checked="'checked' if layout_mode != 'list' else None" value="grid"/>
<label t-attf-class="btn btn-{{navClass}} #{_activeClasses if layout_mode != 'list' else None} o_wsale_apply_grid" title="Grid" for="o_wsale_apply_grid">
@@ -2035,7 +2035,7 @@
</div>
</t>
<t t-else="">
<input type="hidden" name="use_same" t-att-value="partner_id == website_sale_order.partner_shipping_id.id == website_sale_order.partner_invoice_id.id"/>
<input type="hidden" name="use_same" t-att-value="partner_id == website_sale_order.partner_shipping_id.id == website_sale_order.partner_invoice_id.id"/>
</t>
</div>