Skip to content

Commit

Permalink
[REF] *: remove unnecessary/unwanted stuff from kanban archs
Browse files Browse the repository at this point in the history
*fleet,gamification,hr_holidays,lunch,mrp,purchase,stock

Kanban archs are being converted to a simpler API [1]. This is a
long process that requires rewritting/reviewing all kanban archs.
This commit is a followup of those simplications and aims at fixing
some leftovers that have been forgotten/that we didn't see on
review:

 - do not use t-esc to display a field, use the <field> tag instead
   (t-esc still works for now, but by convention and for the sake
   of consistency with the form view, we encourage using <field>)
 - t-att-alt on many2one fields with image widget is useless, the
   correct alt attribute is already generated by the widget.

In particular:
 - some t-esc were done on datetime fields to not display the time,
   we can use a classic <field> with show_time option set to false
 - t-att-alt and t-att-title removed from <field widget="image"/>
   as the first one is useless and the second doesn't work (and the
   name was displayed next to the image anyway).

[1] task~3992107

closes odoo#180398

Signed-off-by: Simon Genin (ges) <[email protected]>
  • Loading branch information
aab-odoo committed Sep 17, 2024
1 parent 6b9d250 commit 8f00209
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 8 deletions.
2 changes: 1 addition & 1 deletion addons/fleet/views/fleet_vehicle_cost_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@
<templates>
<t t-name="kanban-card">
<div class="flex-row">
<field name="vehicle_id" widget="image" options="{'preview_image': 'image_128'}" t-att-alt="record.vehicle_id.value" class="float-start col-2 pe-2"/>
<field name="vehicle_id" widget="image" options="{'preview_image': 'image_128'}" class="float-start col-2 pe-2"/>
<div class="col-10 pe-2 text-truncate">
<field class="fw-bolder" name="vehicle_id"/>
<span t-attf-class="float-end badge #{['todo', 'running'].indexOf(record.state.raw_value) > -1 ? 'text-bg-secondary' : ['cancelled'].indexOf(record.state.raw_value) > -1 ? 'text-bg-danger' : 'text-bg-success'}">
Expand Down
2 changes: 1 addition & 1 deletion addons/gamification/views/gamification_goal_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@
<t t-name="kanban-card" class="text-center">
<field class="fw-bold fs-4" name="definition_id" />
<div class="d-flex justify-content-center mt-3">
<field class="o_image_24_cover me-1 rounded" name="user_id" widget="image" options="{'preview_image': 'avatar_128'}" t-att-title="record.user_id.value" t-att-alt="record.user_id.value"/>
<field class="o_image_24_cover me-1 rounded" name="user_id" widget="image" options="{'preview_image': 'avatar_128'}"/>
<field name="user_id" class="fw-bold"/>
</div>
<div class="pt-3 fs-1 fw-bolder">
Expand Down
2 changes: 0 additions & 2 deletions addons/hr_holidays/views/hr_leave_allocation_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -372,8 +372,6 @@
<field name="employee_id"
widget="image"
options="{'preview_image': 'avatar_128'}"
t-att-title="record.employee_id.value"
t-att-alt="record.employee_id.value"
class="o_image_64_cover float-start mr4"/>
</aside>
<main class="w-100 ps-3">
Expand Down
2 changes: 1 addition & 1 deletion addons/lunch/views/lunch_product_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@
<templates>
<t t-name="kanban-card" class="flex-row">
<aside class="o_kanban_aside_full d-none d-md-block">
<field name="image_128" widget="image" t-att-alt="record.id.value"/>
<field name="image_128" widget="image" alt="Product Image"/>
</aside>
<main>
<div class="d-flex">
Expand Down
3 changes: 2 additions & 1 deletion addons/mrp/views/mrp_workorder_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,8 @@
<field name="production_id"/> - <field name="name"/>
</div>
<div class="o_kanban_workorder_date h5">
<span class="d-flex" t-esc="record.date_start.value or record.production_date.value"/>
<field name="date_start"/>
<field t-if="!record.date_start.raw_value" name="production_date"/>
</div>
<div class="h2 ms-2">
<span t-attf-class="badge #{['progress'].indexOf(record.state.raw_value) > -1 ? 'text-bg-warning' : ['ready', 'waiting', 'pending'].indexOf(record.state.raw_value) > -1 ? 'text-bg-primary' : ['done'].indexOf(record.state.raw_value) > -1 ? 'text-bg-success' : 'text-bg-danger'}">
Expand Down
2 changes: 1 addition & 1 deletion addons/purchase/views/purchase_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@
</div>
<footer class="fs-6 pt-0">
<div class="d-flex">
<field name="name" class="me-1"/> <t t-esc="record.date_order.value and record.date_order.value.split(' ')[0] or False"/>
<field name="name" class="me-1"/> <field name="date_order" options="{'show_time': false}"/>
<field name="activity_ids" widget="kanban_activity" class="ms-1"/>
</div>
<field name="state" widget="label_selection" options="{'classes': {'draft': 'default', 'cancel': 'default', 'done': 'success', 'approved': 'warning'}}" class="ms-auto"/>
Expand Down
2 changes: 1 addition & 1 deletion addons/stock/views/stock_picking_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
<field name="json_popover" nolabel="1" widget="stock_rescheduling_popover" invisible="not json_popover"/>
</div>
<div class="d-flex ms-auto mt-1 align-items-center">
<t t-esc="record.scheduled_date.value and record.scheduled_date.value.split(' ')[0] or False"/>
<field name="scheduled_date" options="{'show_time': false}"/>
<field name="user_id" widget="many2one_avatar_user" invisible="not user_id" readonly="state in ['cancel', 'done']" class="ms-1"/>
</div>
</footer>
Expand Down

0 comments on commit 8f00209

Please sign in to comment.