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

Hi!

I want to use ref on domain field

<field name="domain">[('carrier_id','=',%(fbv_vexpress.carrier_vexpress)d)</field>

but it don't work

Uncaught Error: % undefined as prefix 

How to fix it?

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

Hi Tazan,

Reason : In your code you have not written your domain inside "double quote". Thats why you got an error " % undefined as prefix " 

Solution :

You can use %(xxx)d inside domain. But you need to use as like below.

1) If you are giving domain inside any field definition then you need to define domain as like below.

<field name="M2O_field" domain="[('carrier_id','=',%(fbv_vexpress.carrier_vexpress)d )]" />

2) If you inherit any view and add just domain attribute then you need to define domain as like below.

<field name "M2O_field" position="attributes">
    <attribute name="domain">"[('carrier_id','=',%(fbv_vexpress.carrier_vexpress)d )]"</attribute>
</field>

I hope you are getting what exactly I want to explain. So, in your case (2) is applicable.

Thanks.

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

Nice 1, I have one question when we use attribute than need to double quote?

Thanks for this. I had this problem.

To people having this problem, make sure you don't quote the groupname (fbv_vexpress.carrier_vexpress in this example).

Câu trả lời hay nhất

you can try:

<field name="domain" eval="[('carrier_id', '=', ref('fbv_vexpress.carrier_vexpress'))]"/>
Ảnh đại diện
Huỷ bỏ
Tác giả Câu trả lời hay nhất

@Shamji!

I don't think it work! Because '%(fbv_vexpress.carrier_vexpress)d' is string, not a ref

I want to get id record carrier_vexpress on module fbv_vexpress

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

Tazan,

You may go by an option called search within the field!

<field name="NAME' search="[('model','=','model'),('name','=','your name')]"/>

Its understood that its a DATA, so you may proceed with this check. Also try by ref(XML) too.

Thanks.

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

Haven't tried the search function, but can confirm that ref(XML) does not work (in python file ref throws an error saying it is not defined.) (in xml it throws an error when oyu try to access the field with the message ref is not defined)

Câu trả lời hay nhất

Please try this

[('carrier_id','=','%(fbv_vexpress.carrier_vexpress)d')]

Thanks.

Shamji


Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
0
thg 1 25
1232
1
thg 3 25
652
1
thg 9 23
2382
2
thg 8 22
7631
1
thg 4 20
53