Skip to Content
Odoo Menu
  • Sign in
  • Try it free
  • Apps
    Finance
    • Accounting
    • Invoicing
    • Expenses
    • Spreadsheet (BI)
    • Documents
    • Sign
    Sales
    • CRM
    • Sales
    • POS Shop
    • POS Restaurant
    • Subscriptions
    • Rental
    Websites
    • Website Builder
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Supply Chain
    • Inventory
    • Manufacturing
    • PLM
    • Purchase
    • Maintenance
    • Quality
    Human Resources
    • Employees
    • Recruitment
    • Time Off
    • Appraisals
    • Referrals
    • Fleet
    Marketing
    • Social Marketing
    • Email Marketing
    • SMS Marketing
    • Events
    • Marketing Automation
    • Surveys
    Services
    • Project
    • Timesheets
    • Field Service
    • Helpdesk
    • Planning
    • Appointments
    Productivity
    • Discuss
    • Approvals
    • IoT
    • VoIP
    • Knowledge
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Industries
    Retail
    • Book Store
    • Clothing Store
    • Furniture Store
    • Grocery Store
    • Hardware Store
    • Toy Store
    Food & Hospitality
    • Bar and Pub
    • Restaurant
    • Fast Food
    • Guest House
    • Beverage Distributor
    • Hotel
    Real Estate
    • Real Estate Agency
    • Architecture Firm
    • Construction
    • Estate Management
    • Gardening
    • Property Owner Association
    Consulting
    • Accounting Firm
    • Odoo Partner
    • Marketing Agency
    • Law firm
    • Talent Acquisition
    • Audit & Certification
    Manufacturing
    • Textile
    • Metal
    • Furnitures
    • Food
    • Brewery
    • Corporate Gifts
    Health & Fitness
    • Sports Club
    • Eyewear Store
    • Fitness Center
    • Wellness Practitioners
    • Pharmacy
    • Hair Salon
    Trades
    • Handyman
    • IT Hardware & Support
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Others
    • Nonprofit Organization
    • Environmental Agency
    • Billboard Rental
    • Photography
    • Bike Leasing
    • Software Reseller
    Browse all Industries
  • Community
    Learn
    • Tutorials
    • Documentation
    • Certifications
    • Training
    • Blog
    • Podcast
    Empower Education
    • Education Program
    • Scale Up! Business Game
    • Visit Odoo
    Get the Software
    • Download
    • Compare Editions
    • Releases
    Collaborate
    • Github
    • Forum
    • Events
    • Translations
    • Become a Partner
    • Services for Partners
    • Register your Accounting Firm
    Get Services
    • Find a Partner
    • Find an Accountant
    • Meet an advisor
    • Implementation Services
    • Customer References
    • Support
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Get a demo
  • Pricing
  • Help

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • CRM
  • e-Commerce
  • Accounting
  • Inventory
  • PoS
  • Project
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Tags (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Tags (View all)
odoo accounting v14 pos v15
About this forum
Help

Bug workaround - Dynamic Domains in Studio - Domain not properly formed

Subscribe

Get notified when there's activity on this post

This question has been flagged
filterdomain_filterdynamicfilter_domainStudio
3 Replies
3663 Views
Avatar
IT Consultancy Sàrl

Hi, 


Hosting Variants: All Odoo hosting variants (Odoo SAAS, Odoo.SH, Odoo onPrem)

Versions: Odoo 15.0, Odoo 16.0 (other versions not tested)

App: Studio


Description: 

I try to create a dynamic domain using Studio but constantly receive a "Domain not properly formed" error. 

I have a field named "x_studio_species" which records the species of a record (e.g. "Cat"). 

I have a second field named "x_studio_shelter_box" which records the shelter/box where an animal is located (e.g. Shelter 1: Box 2). 

Both fields are their own models. The model for the shelter_box has a many_to_many (m2m) field named "x_studio_suitable_for" and records the species for which this box is suitable for (e.g. Shelter 1: Box 2 is suitable for Cats, Dogs, and Birds but Shelter 1: Box 1 is suitable only for Dogs). 


Suppose I'm trying to create a domain in Studio for the Animal form which selects only those boxes suitable for the selected species. Thus it should be a dynamic domain that should look like this: 


[["x_studio_suitable_for","like",x_studio_species]]


This however doesn't work, as you can't save the domain that way. It automatically creates it like this: (see quotes for x_studio_species")

[["x_studio_suitable_for","like","x_studio_species"]]


Thus the domain is created with a string instead of a variable. If I'm removing the quotes manually in the window, I get the message "Domain not properly formed"


How can I create a dynamic domain in Studio? ​Is this a bug and if so, is there a workaround?


Thanks in advance

1
Avatar
Discard
Avatar
IT Consultancy Sàrl
Author Best Answer

Hi again, 


Well I finally found the solution. 

When looking at the XML code that gets generated, it looks like this: 

   


So the domain is between double quotes and the respective fields are escaped double-quotes. 


By changing the XML-code of it to: 

   


It works perfectly. The domain is between double quotes but the fields themselves are between single quotes and the variable doesn't have any quotes and is recognized as a variable and not as a string. 


The only downside: I cannot modify the domain using the domain-wizard as this is not parsed correctly now. The form and domain are working correctly though. 



Solution: To create dynamic domains, generate the domain as desired, go (using debug-mode) to the XML file in "View" and modify the escaped double quotes " to ' (single quote). 

1
Avatar
Discard
Hardik Raval

Indeed, this worked for me. I tried to directly write the field name without single quote (') and it worked

Avatar
Eva@Ybo Services
Best Answer

Thanks a lot. I spent a lot of time before I found your answer and it also worked for me.

At the start I had " almost everywhere in my domain, then I changed according to your explanation and now it works perfectly.



Great.

1
Avatar
Discard
Avatar
Adil Akbar
Best Answer

Hi, you can follow this: https://youtu.be/f3mq5fHRPT0

Hope it helps, Thanks

0
Avatar
Discard
Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Sign up
Related Posts Replies Views Activity
Add Filter inside the searchbar dynamically.
filter dynamic searchview filter_domain 17.0
Avatar
0
Jun 24
2173
Odoo 9.0 - Dynamic Custom Search Filter
filter search context dynamic filter_domain
Avatar
Avatar
2
Oct 16
8217
Default Domain Filter
filter domain_filter
Avatar
Avatar
Avatar
2
Jun 22
8120
Trying to filter a list using domain using studio (Odoo V14 Enterprise)
domain_filter Studio
Avatar
Avatar
1
Jul 21
3247
Filtration in xml view
filter domain_filter
Avatar
Avatar
2
Feb 16
4739
Community
  • Tutorials
  • Documentation
  • Forum
Open Source
  • Download
  • Github
  • Runbot
  • Translations
Services
  • Odoo.sh Hosting
  • Support
  • Upgrade
  • Custom Developments
  • Education
  • Find an Accountant
  • Find a Partner
  • Become a Partner
About us
  • Our company
  • Brand Assets
  • Contact us
  • Jobs
  • Events
  • Podcast
  • Blog
  • Customers
  • Legal • Privacy
  • Security
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk slovenščina Español (América Latina) Español ภาษาไทย Türkçe українська Tiếng Việt

Odoo is a suite of open source business apps that cover all your company needs: CRM, eCommerce, accounting, inventory, point of sale, project management, etc.

Odoo's unique value proposition is to be at the same time very easy to use and fully integrated.

Website made with

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now