콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
3 답글
2005 화면

Hi! In ODOO 17, I am trying to change the form view for the res.users model. When I create an heir class, I can add its fields to the parent class. But when I try to add an element using the QWeb, I get an error. Can someone show, how to add an element using the QWeb? What is necessary for the t-set directive to work without errors?


아바타
취소
베스트 답변

Hi,t-set can be used to define a new variable and set its value:

Syntax is,


<t t-set=”variable_name” t-value=”value of the variable” />

Example: 

<t t-set=”count” t-value=”0” />  

This will create a new variable ‘count’ and set its value as zero. We can set the value of this variable using a function.

<t t-set=”count” t-value=”my_function()” />

Here, the value of ‘count’ will be the value returned from the function ‘my_function’. When we define a variable, we don’t need to specify a specific type of this variable. We can have several types of values such as numbers, strings, arrays (lists) and dictionaries, etc. If we need to define a dictionary, we can do it like this,

<t t-set=”my_dict” t-value=”{'my': 'first', 'my2': 'second' }” />

Just like this, we can use lists also. Iterating over the different values of a list or dictionary can be achieved by using a loop.


Hope it helps

아바타
취소
작성자 베스트 답변

Thank you, Savya Sachin!  

When I use expressions like


xpath expr="//label[@for="name"]" position="attributes"
attribute name="string" FIO /attribute
/xpath

(i removed tags)

everything works, but when I insert an expression

xpath expr="//field[@name="name"]" position="after"
t t-set="my_label" Leads /t
/xpath

an error occurs

The forbidden owl directive used in arch (t-set).



아바타
취소
베스트 답변

Hi,

t-set: This attribute signifies that you're using a QWeb directive for setting a variable

t-value: This attribute is used to define the value you want to assign to the variable

You can find many examples of t-set in the default odoo addons code, find an example below for your reference

Thanks

아바타
취소
관련 게시물 답글 화면 활동
0
9월 24
765
1
4월 25
552
0
9월 24
777
0
6월 24
16
1
4월 24
2533