Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
3 Trả lời
10617 Lượt xem

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?

Ảnh đại diện
Huỷ bỏ

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

Câu trả lời hay nhấ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..

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhấ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>

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 8 24
2180
0
thg 12 22
2673
0
thg 7 20
4418
0
thg 11 18
8266
2
thg 3 15
6084