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

Calculated fields in Search Filter, possible?

Abonare

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

Această întrebare a fost marcată
6 Răspunsuri
34422 Vizualizări
Imagine profil
Damien Taylor

Hi Guys,

Is it possible to be able to create a search filter in Odoo based on a calculated/computed field?  It appears it is not possible?

Thanks,
Damien

5
Imagine profil
Abandonează
Imagine profil
Annadurai
Cel mai bun răspuns

We can search non stored field like this :

field_name = fields.Boolean(compute="compute_meth", search='_value_search')

@depends('dependent_field')

def compute_meth(self):

# Your compted code

then

@api.multi

def _value_search(self, operator, value):

    recs = self.search([]).filtered(lambda x : x.field_name is True )

    if recs:

               return [('id', 'in', [x.id for x in recs])]

Now you can get it in list mode as well.

11
Imagine profil
Abandonează
Annadurai

What it does is, whenever you searched in the filter the search method calls the computed method and it returns the value.

Imagine profil
Roman Gsponer
Cel mai bun răspuns

Let me precise the answer form Annadurai with an example:

field_x = fields.Integer('Calculated Value', compute="_compute_field" search="_search_field")

@api.multi
def _search_field(self, operator, value):
field_id = self.search([]).filtered(lambda x : x.field_x == value )
return [('id', operator, [x.id for x in field_id] if field_id else False )]
5
Imagine profil
Abandonează
Imagine profil
Zeinab
Cel mai bun răspuns

I had same problem in having a computed field in filter

The only way is to define a non computed field from the computed one and put it in view. then it will appear in filter

Example:

payment_id = fields.Integer(compute='compute_lastpayment')

payment_state = fields.Char(string='Last Payment State')

 

    @api.multi

    def compute_lastpayment(self):

                for order in self:

                                if order.payment_ids:

                                                payment = order.payment_ids[0]

                                                order.write({'payment_state': payment.state})

 

 

<record model="ir.ui.view" id="purchase_order_tree_inherit">

        <field name="name">purchase.order.tree.inherit</field>

        <field name="model">purchase.order</field>

        <field name="inherit_id" ref="purchase.purchase_order_tree"/>

        <field name="arch" type="xml">

                 <field name="payment_id" invisible="1"/>

                <field name="payment_state"/>

            </field>

        </field>

    </record>

 

0
Imagine profil
Abandonează
Saloua.sahnoune

thank you very much for this solution, I tested it on version 13 and it worked!

Imagine profil
Ray Carnes
Cel mai bun răspuns

Only if you store the field.

See the example of the field END_DATE in the DEFAULT VALUES section of  http://www.odoo.com/documentation/10.0/howtos/backend.html#computed-fields-and-default-values

0
Imagine profil
Abandonează
Imagine profil
Esther Martín
Cel mai bun răspuns

A compute field, by default, is not stored on database. You just need to add stored=True yo the field in Python file. That allows you to filter/group by computed field.

0
Imagine profil
Abandonează
vicky

He is asking about filters, Normally these fields are stored if store = True, but the field is updated it still shows the old values. For that, my solution will work for his case.

Imagine profil
Damien Taylor
Autor Cel mai bun răspuns

Tried add this attribute, but still did not show up in the filter dropdown:

approver_ids = fields.Many2many('res.users', compute="_get_approvers", string="Approvers", stored=True)

also tried

approver_ids = fields.Many2many('res.users', compute="_get_approvers", string="Approvers", stored="True")


However in the filter dropdown, there is no "Approvers" option


-3
Imagine profil
Abandonează
Andre de Kock

I think it should be `stored=True` (remove the quotes)

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
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