Skip to Content
Menu
You need to be registered to interact with the community.
This question has been flagged
3 Odgovori
10407 Prikazi

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
Opusti

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

Best Answer

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
Opusti
Best Answer

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
Opusti
Related Posts Odgovori Prikazi Aktivnost
1
avg. 24
1869
0
dec. 22
2523
0
jul. 20
4291
0
nov. 18
8122
2
mar. 15
5916