Odoo Help

Welcome!

This community 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.

0

[Odoo 8]How to use ref on domain xml

By
Tazan
on 7/9/15, 12:08 AM 1,647 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

Emipro Technologies Pvt. Ltd.

--Emipro Technologies Pvt. Ltd.--
Tiny ERP Pvt Ltd
http://www.odoo.com
5975
| 6 7 8
Rajkot, India
--Emipro Technologies Pvt. Ltd.--

Being an emerging leader in IT market since 2011, Emipro Technologies Pvt. Ltd. has been providing a wide range of business solutions in Odoo & Magento. We are pleased to have a large pool of contented customers with our meticulous work in the domain of ERP & e-Commerce. A ray of relief & satisfaction to  our customers heart by our successful deployment in their organization, purely represents our success in Odoo platform. Hence, we take pride for being an Odoo partner with a vision of expanding our strategic alliances with our customers to offer them high value-added, trustworthy & cost effective solutions.

 

Since establishment, our business has span across 11 countries of the world. Our customers are companies of all sizes ranging from start-ups to large enterprises, who realize that they need a professional business solutions to generate revenue streams, establish proper communication channels or streamline business operations. Standing with strong determination of customer satisfaction, observing each minute detail of their business processes, providing proper guidance and moving forth to develop product accordingly adds our value and reliability among our customers. 

 

We are blessed with efficient, passionate & eclectic young developers who have come across almost all kinds of business profiles, working with full dedication, applying creativity & new features in existing modules and completing customer's projects successfully on predefined target. Our in-depth knowledge while giving business solutions in Odoo allows us to offer following services to our customers :

 

  • Consulting
  • Installation, Configuration & Customization
  • Training & Support
  • Maintenance
  • Upgradation
  • Documentation
  • Crafting community modules
  • Drafting videos on demand
  • Smart Apps development

We will be :) to welcome you @ www.emiprotechnologies.com to solve any kind of your business needs around Odoo. However we are just an inch away from you by email info@emiprotechnologies.com or a tweet to @EmiproTech

Emipro Technologies Pvt. Ltd.
On 7/9/15, 3:03 AM

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

Serpent Consulting Services Pvt. Ltd.

--Serpent Consulting Services Pvt. Ltd.--
4341
| 6 6 8
Gandhinagar, India
--Serpent Consulting Services Pvt. Ltd.--

Serpent Consulting Services Pvt. Ltd. Your Odoo/OpenERP Solution, just an email away!

Serpent Consulting Services Pvt. Ltd.
On 7/9/15, 4:12 AM

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

--Axel Mendoza--
10238
| 7 7 8
Camaguey, Cuba
--Axel Mendoza--

DevOps - Full stack - Software Architect - Developer - Technology Integrator

I could help you to develop anything and solve complex problems based on technologies, integrations and tricky stuffs mostly in Python with OpenERP/Odoo, Zato, Django and many others frameworks programming languages and technologies.

I offers consulting services to anyone with an unanswered questions or needs for customizations. Think about it, maybe it's better to have an expert to solve your issues and projects than having a full time employee trying to understand what to do an how

Reach me at aekroft@gmail.com

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

--Solanki Shamji--
1293
| 5 2 6
Baroda, India
--Solanki Shamji--

Hello!

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

Please try this

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

Thanks.

Shamji


Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

2 follower(s)

Stats

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