跳至內容
選單
此問題已被標幟
3 回覆
10627 瀏覽次數

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?

頭像
捨棄

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

最佳答案

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..

頭像
捨棄
最佳答案

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>

頭像
捨棄
相關帖文 回覆 瀏覽次數 活動
1
8月 24
2186
0
12月 22
2678
0
7月 20
4429
0
11月 18
8266
2
3月 15
6084