Ir al contenido
Menú
Se marcó esta pregunta
1 Responder
1298 Vistas

Hello,

I'm having a hard time calling an external from a Kanban view, so reaching some help here.

My need: I need to change the logic of presentation of "planned_hours" in Project's Task Kanban card (when hr_timesheet module is installed)

So I've done:

1. Created my new and to-be-called QWeb template "kanban_budget_hours" in a module called "carpentry_timesheet":


<template id="kanban_budget_hours">
    <t t-if="record.planned_hours.raw_value &gt; 0 or record.overtime">
        <t t-set="badge" t-value="'border-success'"/>
        <t t-set="badge" t-value="'border-warning'" t-if="record.progress.raw_value &gt; 0"/>
        <t t-set="badge" t-value="'border-danger'" t-if="record.remaining_hours.raw_value &lt; 0"/>
        <div t-attf-class="oe_kanban_align badge {{ badge }}"
            t-attf-title="Remaining hours. Initialy planned: {{ record.planned_hours.raw_value }}h">
            <field name="remaining_hours" digits="[10,0]" />h
        </div>
        
        <t t-set="badge" t-value="'border-danger'" />
        <t t-set="badge" t-value="'border-success'" t-if="record.performance.raw_value &gt; 0"/>
        <div t-if="record.performance.raw_value" t-attf-class="oe_kanban_align badge {{ badge }}" title="Performance">
            <t t-out="'+'" t-if="record.performance.raw_value &gt; 0"/>
            <field name="performance" digits="[2,0]" />%
        </div>
    </t>
</template>


2. Inherited view hr_timesheet.view_task_kanban_inherited_progress like this:


    <record id="view_task_kanban_inherited_progress" model="ir.ui.view">
        <field name="name">project.task.timesheet.kanban.inherited.progress.carpentry</field>
        <field name="model">project.task</field>
        <field name="inherit_id" ref="hr_timesheet.view_task_kanban_inherited_progress" />

        <field name="arch" type="xml">
            <t name="planned_hours" position="replace">
                <t t-call="carpentry_timesheet.kanban_budget_hours" />
            </t>
        </field>
    </record>



Updating the module (CLI -u carpentry_timesheet) works fine but loading the view in web browser gets me the following error:

OwlError: Missing template: "carpentry_timesheet.kanban_budget_hours"

While i can see in Odoo's settings my template correctly created (sorry I can't submit photo so i'm writing here the View content from View settings):

  • view_name: kanban_budget_hours
  • view_type: QWeb
  • model: none
  • active: true
  • inheritance mode: base
  • model data: kanban_budget_hours
  • external_id:  carpentry_timesheet.kanban_budget_hours

Any thoughs ?

Warm welcome

Avatar
Descartar
Autor Mejor respuesta

Just found the answer: it seems that any template called inside a Kanban view must be declared within the tag of the same Kanban view.

So there cannot be call to external template in Kanban. This is less convenient than for report.

Example:

<t t-name="kanban_sub_part">
    Some sub-part of Kanban view
</t>

<t t-name="kanban-box">
    ....
         <t t-call="kanban_sub_part" />
</t>

Avatar
Descartar
Publicaciones relacionadas Respuestas Vistas Actividad
2
jun 16
10339
4
jul 25
1700
1
jul 25
925
1
abr 25
939
0
mar 25
900