İçereği Atla
Menü
Bu soru işaretlendi
3 Cevaplar
10661 Görünümler

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
Vazgeç

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

En İyi Yanıt

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
Vazgeç
En İyi Yanıt

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
Vazgeç
İlgili Gönderiler Cevaplar Görünümler Aktivite
1
Ağu 24
2216
0
Ara 22
2707
0
Tem 20
4453
0
Kas 18
8299
2
Mar 15
6101