Skip to Content
Odoo Meniu
  • Autentificare
  • Try it free
  • Aplicații
    Finanțe
    • Contabilitate
    • Facturare
    • Cheltuieli
    • Spreadsheet (BI)
    • Documente
    • Semn
    Vânzări
    • CRM
    • Vânzări
    • POS Shop
    • POS Restaurant
    • Abonamente
    • Închiriere
    Site-uri web
    • Constructor de site-uri
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Lanț Aprovizionare
    • Inventar
    • Producție
    • PLM
    • Achiziție
    • Maintenance
    • Calitate
    Resurse Umane
    • Angajați
    • Recrutare
    • Time Off
    • Evaluări
    • Referințe
    • Flotă
    Marketing
    • Social Marketing
    • Marketing prin email
    • SMS Marketing
    • Evenimente
    • Automatizare marketing
    • Sondaje
    Servicii
    • Proiect
    • Foi de pontaj
    • Servicii de teren
    • Centru de asistență
    • Planificare
    • Programări
    Productivitate
    • Discuss
    • Aprobări
    • IoT
    • VoIP
    • Knowledge
    • WhatsApp
    Aplicații Terțe Odoo Studio Platforma Odoo Cloud
  • Industrii
    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
    Producție
    • 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
  • Comunitate
    Învăță
    • Tutorials
    • Documentație
    • Certificări
    • Instruire
    • Blog
    • Podcast
    Empower Education
    • Program Educațional
    • Scale Up! Business Game
    • Visit Odoo
    Obține Software-ul
    • Descărcare
    • Compară Edițiile
    • Lansări
    Colaborați
    • Github
    • Forum
    • Evenimente
    • Translations
    • Devino Partener
    • Services for Partners
    • Înregistrează-ți Firma de Contabilitate
    Obține Servicii
    • Găsește un Partener
    • Găsiți un contabil
    • Meet an advisor
    • Servicii de Implementare
    • Referințe ale clienților
    • Suport
    • Actualizări
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Obține un demo
  • Prețuri
  • Ajutor

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

  • CRM
  • e-Commerce
  • Contabilitate
  • Inventar
  • PoS
  • Proiect
  • MRP
All apps
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
All Posts Oameni Insigne
Etichete (View all)
odoo accounting v14 pos v15
Despre acest forum
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
All Posts Oameni Insigne
Etichete (View all)
odoo accounting v14 pos v15
Despre acest forum
Suport

Odoo10: Dynamic domain

Abonare

Primiți o notificare când există activitate la acestă postare

Această întrebare a fost marcată
domaindomain_filtermany2one odoo openerpodoo10
3 Răspunsuri
18706 Vizualizări
Imagine profil
dirtyHandsPHP

Hi, I am trying to add dynamic domain in Odoo 10 Many2one field. Here is the code:


    @api.multi

    def _get_education_domain(self):

        res = {}

        education_list = []

        if self.emeu_sector_id.id:

            education_ids = self.emeu_sector_id.emeu_education_ids

            education_list = [x.id for x in education_ids]

        return [('id', 'in', education_list)]


emeu_education_id = fields.Many2one(

        'emeu.education', string=_('Education'), ondelete='restrict', domain=_get_education_domain)


This throws JSON serialiser error. Can anyone please help me to fix the issue.

 

0
Imagine profil
Abandonează
Imagine profil
Denis Baranov
Cel mai bun răspuns

Hey,

try to keep a value of domain in a separate field. E.g.:

@api.multi
@api.depends("emeu_sector_id.emeu_education_ids")
def _get_education_domain(self):
        for object in self:
              education_list = []
              if object.emeu_sector_id.id:
                   education_ids = object.emeu_sector_id.emeu_education_ids
                   education_list = [x.id for x in education_ids]               object.education_list = [(6,0, education_list)]
education_list = fields.Many2many('emeu.education',store=True,compute=_get_education_domain) emeu_education_id = fields.Many2one('emeu.education', string=_('Education'), ondelete='restrict'])

And on the xml form:

<field name="education_list" invisible="1"/> 
<field name="emeu_education_id" domain="[('id','in',education_list[0][2])]" />
6
Imagine profil
Abandonează
dirtyHandsPHP
Autor

Hey, thanks for your answer but now it's throwing an error:

TypeError: 'Many2many' object does not support indexing

Denis Baranov

Does the domain field is filled properly?

If yes, try one of the followings: to remove [0][2] OR instead put ids

dirtyHandsPHP
Autor

Domain field is populated properly. I already tried both of them and throwing following error:

RuntimeError: maximum recursion depth exceeded while calling a Python object

dirtyHandsPHP
Autor

Hey, I got it fixed. Remove domain attribute from class field emeu_education_id and added in view:

<field name="emeu_education_id" domain="[('id','in',education_list[0][2])]" />

dirtyHandsPHP
Autor

Please update your answer with above comment so that I can accept your answer. Much thanks for your help!! :)

Denis Baranov

glad to hear! the answer was updated

dirtyHandsPHP
Autor

Thanks man!! :)

Imagine profil
Adil Akbar
Cel mai bun răspuns

You can follow this: https://youtu.be/XGqXEL2qQmE 

Hope it helps, Thanks

0
Imagine profil
Abandonează
Imagine profil
Tomás Pascual
Cel mai bun răspuns

Vualá, amazing¡¡¡

I have remove [0][2] for domain xml view, I don't know exactly what this is for.

Thanks man¡¡¡¡

0
Imagine profil
Abandonează
Enjoying the discussion? Don't just read, join in!

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

Înscrie-te
Related Posts Răspunsuri Vizualizări Activitate
Domain filter Rezolvat
domain user domain_filter odoo10
Imagine profil
Imagine profil
1
dec. 23
19452
Condition Drop Down Items
domain domain_filter
Imagine profil
0
feb. 25
18
Domain filter between two models that are connected to the third model via M2O relation. Rezolvat
domain_filter odoo10
Imagine profil
1
iul. 19
5668
Construct a "domain=" across many2many fields Rezolvat
domain domain_filter
Imagine profil
Imagine profil
2
mar. 15
7729
Domain filters by followers
domain domain_filter
Imagine profil
0
mar. 15
4268
Comunitate
  • Tutorials
  • Documentație
  • Forum
Open Source
  • Descărcare
  • Github
  • Runbot
  • Translations
Servicii
  • Hosting Odoo.sh
  • Suport
  • Actualizare
  • Custom Developments
  • Educație
  • Găsiți un contabil
  • Găsește un Partener
  • Devino Partener
Despre Noi
  • Compania noastră
  • Active de marcă
  • Contactați-ne
  • Locuri de muncă
  • Evenimente
  • Podcast
  • Blog
  • Clienți
  • Aspecte juridice • Confidențialitate
  • Securitate
الْعَرَبيّة 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 este o suită de aplicații de afaceri open source care acoperă toate nevoile companiei dvs.: CRM, comerț electronic, contabilitate, inventar, punct de vânzare, management de proiect etc.

Propunerea de valoare unică a Odoo este să fie în același timp foarte ușor de utilizat și complet integrat.

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