Passa al contenuto
Menu
È necessario essere registrati per interagire con la community.
La domanda è stata contrassegnata
1 Rispondi
261 Visualizzazioni

I want to override the following template from Odoo 18 enterprise source code (specifically I want to override the <t t-out="availableResource['name']"/> and replace it with <t t-out="availableResource['display_name']"/>:


<?xml version="1.0" encoding="UTF-8"?>

<template>

    <t t-name="appointment.resources_list">

        <label for="resource_id" class="mb-1">Make your choice</label>

        <select class="o_resources_list form-select cursor-pointer" name="resource_id">

            <t t-if="scheduleBasedOn === 'resources'">

                <option t-foreach="availableResources" t-as="availableResource" t-key="availableResource_index"

                    t-att-value="availableResource['id']" t-att-data-resource-capacity="availableResource['capacity']">

                    <t t-out="availableResource['name']"/>

                </option>

            </t>

            <option t-else="" t-foreach="availableStaffUsers" t-as="availableUser" t-key="availableUser_index"

                t-att-value="availableUser['id']">

                <t t-out="availableUser['name']"/>

            </option>

        </select>

        <button name="submitSlotInfoSelected" class="btn btn-primary w-100 mt-3">Confirm</button>

    </t>

</template>

The problem is that the template has no id and it is rendered from a js file using renderToFragment:

this.resourceSelectionEl.replaceChildren(

            renderToFragment("appointment.resources_list", {

                availableResources,

                availableStaffUsers,

                scheduleBasedOn,

            })

        );

If it means anything the template is used for displaying the select table drop down list in website restaurant table booking. The file is located at appointment/static/src/xml/appointment_resources.xml and the js file that renders it is at appointment/static/src/js/appointment_select_appointment_slot.js 


How can I inherit this template with no id?

Avatar
Abbandona
Risposta migliore

You can find further details under the Template inheritance section in https://www.odoo.com/documentation/18.0/developer/reference/frontend/qweb.html#template-inheritance

So, an inheritance would be done similar to this:

<t t-inherit="appointment.resources_list" t-inherit-mode="extension">
    <xpath expr="//select/t/option/t" position="attributes">
        <attribute name="t-out">availableResource['display_name']</attribute>
    </xpath>
</t>
Avatar
Abbandona
Post correlati Risposte Visualizzazioni Attività
2
mag 25
4433
2
lug 25
294
1
giu 25
689
4
mag 25
905
0
mar 25
842