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
    • Magazin de îmbrăcăminte
    • Magazin de Mobilă
    • Magazin alimentar
    • Magazin de materiale de construcții
    • Magazin de jucării
    Food & Hospitality
    • Bar and Pub
    • Restaurant
    • Fast Food
    • Guest House
    • Distribuitor de băuturi
    • Hotel
    Proprietate imobiliara
    • Real Estate Agency
    • Firmă de Arhitectură
    • Construcție
    • Estate Managament
    • Grădinărit
    • Asociația Proprietarilor de Proprietăți
    Consultanta
    • Firma de Contabilitate
    • Partener Odoo
    • Agenție de marketing
    • Law firm
    • Atragere de talente
    • Audit & Certification
    Producție
    • Textil
    • Metal
    • Mobilier
    • Mâncare
    • Brewery
    • Cadouri corporate
    Health & Fitness
    • Club Sportiv
    • Magazin de ochelari
    • Centru de Fitness
    • Wellness Practitioners
    • Farmacie
    • Salon de coafură
    Trades
    • Handyman
    • IT Hardware and Support
    • Asigurare socială de stat
    • Cizmar
    • Servicii de curățenie
    • HVAC Services
    Altele
    • Organizație nonprofit
    • Agenție de Mediu
    • Închiriere panouri publicitare
    • Fotografie
    • Închiriere biciclete
    • Asigurare socială
    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

how can use output of function in domain of field?

Abonare

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

Această întrebare a fost marcată
domainodoo11
2 Răspunsuri
8649 Vizualizări
Imagine profil
mitra safari

Hello Odoo community!
I write a function that calculates  day and then return today food ,how can i use this output as domain of product_id field?

column:

product_id = fields.Many2one('lunch.product', 'Product', required=True , domain="[???]")

my function:

def _menu(self):
"""
Prevents menu list
"""
day = self.env['lunch.menu'].search([]).mapped('day')
order_day = self.env['lunch.order'].search([]).mapped('date')
day_name = datetime.datetime.now().strftime('%A')
res={}
for order in self:
    for d in range (0,len(day)):
        if  day[d] == day_name:
            menu = self.env['lunch.menu'].search([('day' ,'=' ,day_name)]).mapped('product.id')
return menu



0
Imagine profil
Abandonează
Sehrish

You must read this docs: Learn OpenERP is a great platform where you can specially learn OpenERP (odoo) and its programming concepts from A to Z. The purpose of creating this blog is to help those people who wants to develop their own OpenERP Systems. Have a look please:

https://goo.gl/8HgnCF

Imagine profil
faOtools
Cel mai bun răspuns

You can not use the result of methods in a domain, since the used domain criteria (field) should be present on a view.

However, you can compute field and place it to the form. Something like,

@api.multi
def _compute_menu_id(self):
for obj in self:
# the logic to define menu_id for this object
obj.menu_id = menu_id

product_id = fields.Many2one(
'lunch.product',
'Product',
required=True ,
domain=[("FOODFIELD", '=', menu_id)], #FOODFIELD should be a stored field of lunch.product field
)
menu_id = fields.Many2one(
"lunch.menu",
compute=_compute_menu_id,
) 
0
Imagine profil
Abandonează
Lincoln Eddy

I am trying to do something similar, and falling at the last hurdle.

I am trying to filter a Many2One field called attribute_type_id
I have added a One2Many field called valid_attrtype_ids
Using a compute method I am successfully populating valid_attrtype_ids with the set of records that I want to be able to select from. This field is visible, so I can see that it is populating correctly.

I am attempting to set a domain filter on attribute_type_id to only show the records that are in valid_attrtype_ids.

Here's my current syntax (I've tried this a few different ways):

<field name="attribute_type_id">
domain="[('id', 'in', valid_attrtype_ids)]"
</field>

I'm not getting any errors, however the field attribute_type_id is not being filtered. It is showing all records from the underlying model.

Any suggestions?

Imagine profil
Rishan Malaka
Cel mai bun răspuns

Hi,

This will helpful for you - \https://www.linkedin.com/pulse/how-set-dynamic-domain-filter-many2one-field-odoo-rishan-malaka?trk=portfolio_article-card_title

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
Update many2one field domain with respect to onchange of selection field in another model. Is it possible ?
domain odoo11
Imagine profil
Imagine profil
1
iul. 18
10272
How to get one2many / many2one field in report - Odoo11 Enterprise
domain one2many odoo11
Imagine profil
Imagine profil
Imagine profil
4
nov. 20
8764
[11.0] How can i pass self value to domain
domain domain_filter odoo11
Imagine profil
0
aug. 19
4311
create backorder odoo after validate purchase shipment ? Rezolvat
odoo11
Imagine profil
Imagine profil
1
oct. 25
11850
naked domain set up Rezolvat
domain
Imagine profil
Imagine profil
Imagine profil
Imagine profil
3
iul. 25
5959
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