Odoo Help

0

[Odoo 8]How to use ref on domain xml

By
Tazan
on 7/9/15, 12:08 AM 2,462 views

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?

3

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.

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

Solanki Shamji
on 7/9/15, 7:51 AM
1
Tazan
On 7/9/15, 2:59 AM

@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

1

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.

0
Axel Mendoza
On 7/10/15, 2:14 AM

Also you could define a function field in your target model that search for the needed id and then use it like this:

[code]

<field name="carrier_vexpress" invisible="1"/>

<field name="target_field_id" domain="[('carrier_id','=', carrier_vexpress)]" />

[/code]

0
Solanki Shamji
On 7/9/15, 2:53 AM

Please try this

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

Thanks.

Shamji


About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

Register

Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

2 follower(s)

Stats

Asked: 7/9/15, 12:08 AM
Seen: 2462 times
Last updated: 7/10/15, 2:14 AM