Skip to Content
Odoo Menu
  • Prihlásiť sa
  • Vyskúšajte zadarmo
  • Aplikácie
    Financie
    • Účtovníctvo
    • Fakturácia
    • Výdavky
    • Tabuľka (BI)
    • Dokumenty
    • Podpis
    Predaj
    • CRM
    • Predaj
    • POS Shop
    • POS Restaurant
    • Manažment odberu
    • Požičovňa
    Webstránky
    • Tvorca webstránok
    • eShop
    • Blog
    • Fórum
    • Živý chat
    • eLearning
    Supply Chain
    • Sklad
    • Výroba
    • Správa životného cyklu produktu
    • Nákup
    • Údržba
    • Manažment kvality
    Ľudské zdroje
    • Zamestnanci
    • Nábor zamestnancov
    • Voľné dni
    • Hodnotenia
    • Odporúčania
    • Vozový park
    Marketing
    • Marketing sociálnych sietí
    • Email marketing
    • SMS marketing
    • Eventy
    • Marketingová automatizácia
    • Prieskumy
    Služby
    • Projektové riadenie
    • Pracovné výkazy
    • Práca v teréne
    • Helpdesk
    • Plánovanie
    • Schôdzky
    Produktivita
    • Tímová komunikácia
    • Schvalovania
    • IoT
    • VoIP
    • Znalosti
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Priemyselné odvetvia
    Retail
    • Book Store
    • Clothing Store
    • Furniture Store
    • Grocery Store
    • Hardware Store
    • Toy Store
    Food & Hospitality
    • Bar and Pub
    • Reštaurácia
    • Fast Food
    • Guest House
    • Beverage distributor
    • Hotel
    Reality
    • Real Estate Agency
    • Architecture Firm
    • Konštrukcia
    • Estate Managament
    • Gardening
    • Property Owner Association
    Poradenstvo
    • Accounting Firm
    • Odoo Partner
    • Marketing Agency
    • Law firm
    • Talent Acquisition
    • Audit & Certification
    Výroba
    • Textile
    • Metal
    • Furnitures
    • Jedlo
    • Brewery
    • Corporate Gifts
    Health & Fitness
    • Sports Club
    • Eyewear Store
    • Fitness Center
    • Wellness Practitioners
    • Pharmacy
    • Hair Salon
    Trades
    • Handyman
    • IT Hardware and Support
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Iní
    • Nonprofit Organization
    • Environmental Agency
    • Billboard Rental
    • Photography
    • Bike Leasing
    • Software Reseller
    Browse all Industries
  • Komunita
    Vzdelávanie
    • Tutoriály
    • Dokumentácia
    • Certifikácie
    • Školenie
    • Blog
    • Podcast
    Empower Education
    • Vzdelávací program
    • Scale Up! Business Game
    • Visit Odoo
    Softvér
    • Stiahnuť
    • Porovnanie Community a Enterprise vierzie
    • Releases
    Spolupráca
    • Github
    • Fórum
    • Eventy
    • Preklady
    • Staň sa partnerom
    • Services for Partners
    • Register your Accounting Firm
    Služby
    • Nájdite partnera
    • Nájdite účtovníka
    • Meet an advisor
    • Implementation Services
    • Zákaznícke referencie
    • Podpora
    • Upgrades
    ​Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Získajte demo
  • Cenník
  • Pomoc

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

  • CRM
  • e-Commerce
  • Účtovníctvo
  • Sklady
  • PoS
  • Projektové riadenie
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Tagy (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Tagy (View all)
odoo accounting v14 pos v15
About this forum
Pomoc

How to write a Domain in a filter? [SOLVED]

Odoberať

Get notified when there's activity on this post

This question has been flagged
filterdomainv7
1 Odpoveď
14791 Zobrazenia
Avatar
Yannick Gerard

Hello, I know my question seems kinda dumb (there is an attribute "domain" so what's the point ?) but here's my problem:

I created a default filter:

<filter string="My Validations" icon="terp-personal" name="my_validations"
domain="['|',('employee_id.parent_id.user_id','=', uid),'&amp;',('employee_id.coach_id.user_id','=',uid),('state', '=', 'validate1')]"
help="My validations"/>

with this domain, I have no problem, but it's not exactly what I want ... i want to add an other constraint: state = confirm so I tried many things and nothing worked (in order to have something like ( employee.parent AND state confirm) OR (employee.coach AND state validate1)

domain="['&amp;',('employee_id.parent_id.user_id','=', uid),'|',('state','=','confirm'),'&amp;',('employee_id.coach_id.user_id','=',uid),('state', '=', 'validate1')]" 

This one works, but only for the first part (employee.parent and confirm), the second one is not seen.


domain="['|',('&amp;',('employee_id.parent_id.user_id','=', uid),('state','=','confirm')),('&amp;',('employee_id.coach_id.user_id','=',uid),('state', '=', 'validate1'))]"  

This one throw an error " Invalid leaf ['&', ['employee_id.parent_id.user_id', '=', 316], ['state', '=', 'confirm']]"


domain="['|',['&amp;',('employee_id.parent_id.user_id','=', uid),('state','=','confirm')],['&amp;',('employee_id.coach_id.user_id','=',uid),('state', '=', 'validate1')]]"   

And this one throw an error "TypeError:results.groupby is undefined"

And I'm lost ... I don't know what to try now ...

Please ... Help ç_ç


0
Avatar
Zrušiť
Avatar
Temur
Best Answer

a problem is that you're trying to use wrong notation, you've to write odoo domains using prefix notation.

The main advantage of prefixed/postfixed operators are to avoid to use brackets for determine a sequence of calculation. in these domains there is used prefixed notation, so each operator takes it's following operands. there is no need to use extra brackets.

I'll take fseudocode from your question and transform it step by step:

you wrote

in order to have something like ( employee.parent AND state confirm) OR (employee.coach AND state validate1)

(BTW you've written above statement using infix notation, in order to get worked it in odoo domains, we've to transform it into the prefix notation)

first transform statements in the brackets, move AND condition to the start of each of them:

(AND, employee.parent , state confirm) OR ( AND, employee.coach , state validate1) 

-here AND takes it's two following arguments, then it's caclulated and considered as argument for OR.  (same for another AND), now move the OR operator to the left of it's arguments:

OR, (AND, employee.parent , state confirm),( AND, employee.coach , state validate1)

but here brackets are extra, they can't determine anything in rapport of sequence of calculation, each AND takes it's following two operands(as binary operator), and OR takes it's following two operands as well (results of two AND). so now we remove brackets, and your fseudo statement will become something as:

OR, AND, employee.parent , state confirm, AND, employee.coach , state validate1

-it's prefix notation equivalent of your infix notation fseudostatement.

of course you'll have some other brackets in real domain statement, but not the ones used for sequence/prioritize calculations.

you'll have something like:

domain="['|','&amp;',('employee_id.parent_id.user_id','=', uid),('state','=','confirm'),'&amp;',('employee_id.coach_id.user_id','=',uid),('state', '=', 'validate1')]" 

2
Avatar
Zrušiť
Enjoying the discussion? Don't just read, join in!

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

Registrácia
Related Posts Replies Zobrazenia Aktivita
How can i use a field function in the domain filter? Solved
filter domain v7
Avatar
Avatar
Avatar
Avatar
3
mar 15
21155
Filter meetings where I'm an attendee
filter domain v7 meeting
Avatar
Avatar
Avatar
Avatar
3
júl 20
8718
Filtering messages not working
filter domain v7 messages
Avatar
0
mar 15
4578
How to use AND / OR operators in advanced filters? Solved
filter v7
Avatar
Avatar
Avatar
Avatar
3
apr 23
34938
Filter many2one field with functional field
filter domain
Avatar
Avatar
Avatar
5
sep 20
13484
Komunita
  • Tutoriály
  • Dokumentácia
  • Fórum
Open Source
  • Stiahnuť
  • Github
  • Runbot
  • Preklady
Služby
  • Odoo.sh hosting
  • Podpora
  • Vyššia verzia
  • Custom Developments
  • Vzdelávanie
  • Nájdite účtovníka
  • Nájdite partnera
  • Staň sa partnerom
O nás
  • Naša spoločnosť
  • Majetok značky
  • Kontaktujte nás
  • Pracovné ponuky
  • Eventy
  • Podcast
  • Blog
  • Zákazníci
  • Právne dokumenty • Súkromie
  • Bezpečnosť
الْعَرَبيّة 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 je sada podnikových aplikácií s otvoreným zdrojovým kódom, ktoré pokrývajú všetky potreby vašej spoločnosti: CRM, e-shop, účtovníctvo, skladové hospodárstvo, miesto predaja, projektový manažment atď.

Odoo prináša vysokú pridanú hodnotu v jednoduchom použití a súčasne plne integrovanými biznis aplikáciami.

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