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 to filter a domain view with a function? In odoo 9

Abonare

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

Această întrebare a fost marcată
domainviewdomain_filterodoo9
1 Răspunde
17479 Vizualizări
Imagine profil
Baintex Technologies S.L.

I want to filter a domain with a function instead of a variable in order to show only some registers in the view.

I have done this:

 

 class SaleOrderExt(models.Model):
  _inherit = ['sale.order']
  @api.multi
  def custom_funct_date(self):
   my_date = ... (some stuff)
   return my_date

Then, in the view, I have filtered the domain:

 

    <?xml version="1.0"?>
    <openerp>
      <data>
        <record id='action_menu_custom_date' model='ir.actions.act_window'>
          <field name="name">This is a test</field>
          <field name="res_model">sale.order</field>
          <field name="view_type">form</field>
          <field name="view_mode">tree,form</field>
          <field name="domain">[('date_order','>=',custom_funct_date)]</field>
        </record>
      </data>
    </openerp>

But this is giving me an error:

    ValueError: "name 'custom_funct_date' is not defined" while evaluating
    u"[('date_order','>=',custom_funct_date)]"
0
Imagine profil
Abandonează
Imagine profil
Divya-vyas
Cel mai bun răspuns

Hello

I suggest you to add one more field which is compute field. and then pass in domain. use custom_funct_date method in that new compute field.


1
Imagine profil
Abandonează
Baintex Technologies S.L.
Autor

Okay, I have tried this too: my_date = fields.Datetime(string="Computed date", compute="custom_funct_date")

But it gives me that error: ValueError: "name 'my_date' is not defined" while evaluating u"[('date_order','>=', my_date)]"

Divya-vyas

it's wrong syntax.

try this one.

"[('date_order','>=', 'my_date')]"

Divya-vyas

also add my_date on view file and set invisible = 1

Baintex Technologies S.L.
Autor

DataError: invalid input syntax for type timestamp: "my_date"

LÍNEA 1: ...ids"."res_id") AND (("sale_order"."date_order" >= 'my_date...

Divya-vyas

did you add field in form view?

Baintex Technologies S.L.
Autor

I think so. In my custom view, the field appears (if I quit the part of invisible).

Divya-vyas

make sure your compute function return proper date format like sale_order.date_order,

try also without ('date_order','>=', my_date)

Divya-vyas

*with ('date_order','>=', my_date)

Baintex Technologies S.L.
Autor

Checked and same result :(

Baintex Technologies S.L.
Autor

I think that if I put this:

('date_order','>=', my_date)

my_date is treated as a variable, and that variable doesn't exist.

If I put:

('date_order','>=', 'my_date')

'my_date' is treated as a string, and gives an error, because a string doen't have a datetime type

salah BELHAMICHE

Any solution For this problem ? i have the same use case.

Baintex Technologies S.L.
Autor

Look at this:

https://stackoverflow.com/questions/43733825/how-to-filter-a-domain-view-with-a-function-in-odoo-9

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
How can I pass more than one field to a search function? In Odoo 9 Rezolvat
domain view search domain_filter odoo9
Imagine profil
Imagine profil
Imagine profil
Imagine profil
6
sept. 20
20764
Condition Drop Down Items
domain domain_filter
Imagine profil
0
feb. 25
18
[odoo 11] A problem of domain as strings on xml file Rezolvat
domain view
Imagine profil
Imagine profil
Imagine profil
2
mai 18
5217
How can I use domain filter with a function to hide lines in a treeview in odoo 9?
filter domain domain_filter function_field odoo9
Imagine profil
Imagine profil
Imagine profil
2
sept. 16
8652
how to access another models fields from view (xml) file
domain view
Imagine profil
Imagine profil
Imagine profil
2
mar. 15
13459
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