Se rendre au contenu
Menu
Cette question a été signalée
3 Réponses
10413 Vues

I added a boolean field to my `stock.picking.type` model called `x_is_dropship_aggregate_picking_type`. This field is `False` for all picking types in my database except for one.

I am trying to make some changes to the Kanban card for the picking type that has `x_is_dropship_aggregate_picking_type == true`, but I can't seem to get it to work.

Here's my template created through the Odoo V10 UI. It inherits from the `stock.picking.type.kanban` view:

<?xml version="1.0"?>

<data>

<xpath expr="//field[@name='count_picking_backorders']" position="after">

<field name="x_is_dropship_aggregate_picking_type"/>

</xpath>

<templates>

<t t-extend="kanban-box">

<t t-if="record.x_is_dropship_aggregate_picking_type.raw_value" t-jquery="button" t-operation="replace">

<button class="btn btn-primary">

<span>100 To Receive</span>

</button>

</t>

</t>

</templates>

</data>

As you can see on this line:

    <t t-if="record.x_is_dropship_aggregate_picking_type.raw_value" t-jquery="button" t-operation="replace">

I am attempting to only alter the parent template if the value of this field is `true`. Unfortunately, every Kanban card within the view is getting changed, not just the one I want. It seems that `t-if` and `t-jquery` do not working together in that way.

Is there any way to conditionally alter this view and leave it unchanged otherwise?

Avatar
Ignorer

Thanks for the suggestion Hilar but that does not work. There has to be a t-jquery element immediately after t-extend. I tried your solution and got the following error when the page is loaded:

Uncaught Error: QWeb2: Error while extending template 'kanban-boxNo expression given

Meilleure réponse

Hello,

Try this method

You can replace the button and give the actual code if the field is set false.And your code if it is true:

<t t-extend="kanban-box">

<t t-jquery="button" t-operation="replace">

<t t-if="record.x_is_dropship_aggregate_picking_type.raw_value === true">

<button class="btn btn-primary">

<span>100 To Receive</span>

</button>

</t>

<t t-if="record.x_is_dropship_aggregate_picking_type.raw_value === false">

/// actual code of the button replaced

</t>

</t>

</t>


Hope this helps..

Avatar
Ignorer
Meilleure réponse

Hi,

please try:

<t t-extend="kanban-box">
     <t t-if="record.x_is_dropship_aggregate_picking_type.raw_value">

<!--t-if="record.x_is_dropship_aggregate_picking_type.raw_value === true-->

         <t t-jquery="button" t-operation="replace">
              <button class="btn btn-primary">
             <span>100 To Receive</span>
            </button>

         </t>
    </t>
</t>

Avatar
Ignorer
Publications associées Réponses Vues Activité
1
août 24
1874
0
déc. 22
2527
0
juil. 20
4297
0
nov. 18
8123
2
mars 15
5918