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
  • 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 Managament
    • Gardening
    • Property Owner Association
    Consulting
    • Accounting Firm
    • Odoo Partner
    • Marketing Agency
    • Law firm
    • Talent Acquisition
    • Audit & Certification
    Výroba
    • Textile
    • Metal
    • Furnitures
    • Food
    • 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
    Others
    • 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
  • Help

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

Filter using domain in a many2many relation view

Odoberať

Get notified when there's activity on this post

This question has been flagged
domainmany2many
9 Replies
50212 Zobrazenia
Avatar
Alessandro Pillan

Hi all, I'm trying to understand how domain works in tree view for a many2many relationship in OpenERP 7.0. This is a dummy class Places:

class place_type(Model):
    _name = "place.type"
    _description = "Place Type"
    _columns = {
        'name': fields.char('Name', size=16, required=True),
    }
    _order = 'name asc'

place_type()

class place(Model):
    _name = "place"
    _description = "Place"
    _columns = {
        'name': fields.char('Name', size=64, required=True),
        'type': fields.many2one('place.type', string='Type'),
    }
    _order = 'name asc'

place_type()

class res_partner(Model):
    _inherit = 'res.partner'
    _columns = {
        'place_ids': fields.many2many('place', string="Dummy Places"),
    }

res_partner()

I'm just adding to partners some places defined by a name and a type, this is my view:

<!-- places page addition to partner form -->
<record model="ir.ui.view" id="view_partner_form_with_dummy_places">
        <field name="name">res.partner.form</field>
        <field name="model">res.partner</field>
        <field name="inherit_id" ref="base.view_partner_form"/>
        <field name="arch" type="xml">
            <xpath expr="(sheet/notebook/page)[last()]" position="after">
                <page string="Dummy Places">
                    <field name="place_ids" domain="('type', '=', 4)"/>
                </page>
            </xpath>
        </field>
</record>

I've tried in many ways to make domain working, in this case "4" is a real type id.
I also tried to insert obviously wrong domain statements, without getting any feedback error neither in server log nor in javascript console.
Is it completly ignored?
Latter, what I want to achieve is dynamically filtering partner places by a select field , is it possible?
I really appreciate any help!

0
Avatar
Zrušiť
evon_dun

I want to use partner's name from 'partner_ids' field which is a 'many2many' field in the 'partner.ledger.webkit' model, in the attachment prefix for the report 'Partner Ledger Report' example 'object.company_id.name.pdf'. Please help!

Avatar
René Schuster
Best Answer

The domain is a list of tuples, so use a list:

<field name="place_ids" domain="[('type', '=', 4)]"/>

 

Regards.

3
Avatar
Zrušiť
Avatar
Andre de Kock
Best Answer



1
Avatar
Zrušiť
Avatar
Gabriel
Best Answer

Hi Allessandro,

Update:

Domain is not a valid attribute for the field object in xml view.

It is however possible to define a functional field to filter a x2many field. Further information can be found in the nice Andreas Brueckl answer.


Have you tried: domain="('type.id', '=', 4)" instead of: domain="('type', '=', 4)" ?

For the dynamic filtering, you may try something like:

class res_partner(Model):
    _inherit = 'res.partner'
    _columns = {
        'type_id': fields.many2one('place.type', string='Type'),
        'place_ids': fields.many2many('place', string="Dummy Places"),
    }
res_partner()

And in the XML view:

<page string="Dummy Places">
   <field name="type_id" />
   <field name="place_ids" domain="('type.id', '=', type_id)"/>
</page>
1
Avatar
Zrušiť
Alessandro Pillan
Autor

Domain is still not working, now it doesn't show any record. But when I try to add a new place now it throw an error, it may be helpful:

File "/home/openerp/server/openerp/osv/expression.py", line 582, in check_leaf raise ValueError("Invalid leaf %s" % str(self.leaf)) ValueError: Invalid leaf type.id

Gabriel

Can we have more details on what you are intending to do. Would you like to hide some records of the existing many2many links or filter the Add tree view displayed when adding a new record?

Alessandro Pillan
Autor

Yes, sorry, I would like to hide records where type is not equal to something. Next step field type_id added on your view should be a select

Gabriel

It seems that domain is not working when it is defined in XML view. I tried as well by adding a filter through a search view, and unfortunately it does not seems to work neither.

Finally what worked for a similar case where I had to display two times the same one2many field on the same view with different filters was to create two functional fields returning the filtered ids.

In your case one functional field returning the ids of place_ids that have the specified type_id would probably make it.

evon_dun

I want to use partner's name from 'partner_ids' field which is a 'many2many' field in the 'partner.ledger.webkit' model, in the attachment prefix for the report 'Partner Ledger Report' example 'object.company_id.name.pdf'. Please help!

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
Many2many domain works when click search more but wrong values in dropdown
domain many2many
Avatar
0
nov 22
80
[SOLVED] Create rule using many2many - how to? Solved
domain many2many
Avatar
1
jún 22
8087
Many2many domain not working Solved
domain many2many
Avatar
1
júl 21
3498
Many2many domain not working Solved
domain many2many
Avatar
Avatar
1
júl 21
5008
Domain for Many2many fields
domain many2many
Avatar
Avatar
1
okt 15
11613
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