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

Hello guys, in Odoo Qweb i saw t-if condition use in different ways, exp:
- t-if="record.use_leads.raw_value"

- t-if="widget.editable"

- t-if="team.portal_show_rating"
- t-if="employee.department_id"
....
I just do not understand where the "record", "widget", "team", " employee" come from, especially is "widget" because i see it so many times and it makes me so confused. Thanks!



Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Hi,

These are the variable/data passed from the corresponding controllers that render this page.

Thanks

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Hi,

Qweb has different conditional directives. ‘t-if’ is one of them. If the given condition is true, then the element is rendered. If the condition is false, the element is not rendered.

Eg:

<t t-set="inv_ids" t-value="doc.origin"/> <t t-set="sale_order" t-value="request.env['sale.order'].search([('invoice_ids','=',inv_ids)])"/> <t t-foreach="sale_order" t-as="line">   <t t-if="http://line.name/" rel="noopener nofollow noreferrer" target="_blank">line.name"> <strong t-esc="http://line.name/" rel="noopener nofollow noreferrer" target="_blank">line.name"/> </t> </t>


QWeb has an iteration directive ‘t-foreach’ which takes an expression returning the collection to iterate on, and a second parameter ‘t-as’ provides the name to use for the "current item" of the iteration.
Here we are iterating ‘sale_order’ with parameter ‘line’.

Regards

Ảnh đại diện
Huỷ bỏ
Tác giả Câu trả lời hay nhất

thanks you 2 of you very much, just don't enough karma to upvote for you @@

Ả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 23
1811
2
thg 12 24
9293
0
thg 11 23
3548
2
thg 4 23
8650
1
thg 10 22
6450