Passa al contenuto
Odoo Menu
  • Accedi
  • Provalo gratis
  • App
    Finanze
    • Contabilità
    • Fatturazione
    • Note spese
    • Fogli di calcolo (BI)
    • Documenti
    • Firma
    Vendite
    • CRM
    • Vendite
    • Punto vendita Negozio
    • Punto vendita Ristorante
    • Abbonamenti
    • Noleggi
    Siti web
    • Configuratore sito web
    • E-commerce
    • Blog
    • Forum
    • Live chat
    • E-learning
    Supply chain
    • Magazzino
    • Produzione
    • PLM
    • Acquisti
    • Manutenzione
    • Qualità
    Risorse umane
    • Dipendenti
    • Assunzioni
    • Ferie
    • Valutazioni
    • Referral dipendenti
    • Parco veicoli
    Marketing
    • Social marketing
    • E-mail marketing
    • SMS marketing
    • Eventi
    • Marketing automation
    • Sondaggi
    Servizi
    • Progetti
    • Fogli ore
    • Assistenza sul campo
    • Helpdesk
    • Pianificazione
    • Appuntamenti
    Produttività
    • Comunicazioni
    • Approvazioni
    • IoT
    • VoIP
    • Knowledge
    • WhatsApp
    App di terze parti Odoo Studio Piattaforma cloud Odoo
  • Settori
    Retail
    • Libreria
    • Negozio di abbigliamento
    • Negozio di arredamento
    • Alimentari
    • Ferramenta
    • Negozio di giocattoli
    Cibo e ospitalità
    • Bar e pub
    • Ristorante
    • Fast food
    • Pensione
    • Grossista di bevande
    • Hotel
    Agenzia immobiliare
    • Agenzia immobiliare
    • Studio di architettura
    • Edilizia
    • Gestione immobiliare
    • Impresa di giardinaggio
    • Associazione di proprietari immobiliari
    Consulenza
    • Società di contabilità
    • Partner Odoo
    • Agenzia di marketing
    • Studio legale
    • Selezione del personale
    • Audit e certificazione
    Produzione
    • Tessile
    • Metallo
    • Arredamenti
    • Alimentare
    • Birrificio
    • Ditta di regalistica aziendale
    Benessere e sport
    • Club sportivo
    • Negozio di ottica
    • Centro fitness
    • Centro benessere
    • Farmacia
    • Parrucchiere
    Commercio
    • Tuttofare
    • Hardware e assistenza IT
    • Ditta di installazione di pannelli solari
    • Calzolaio
    • Servizi di pulizia
    • Servizi di climatizzazione
    Altro
    • Organizzazione non profit
    • Ente per la tutela ambientale
    • Agenzia di cartellonistica pubblicitaria
    • Studio fotografico
    • Punto noleggio di biciclette
    • Rivenditore di software
    Carica tutti i settori
  • Community
    Apprendimento
    • Tutorial
    • Documentazione
    • Certificazioni 
    • Formazione
    • Blog
    • Podcast
    Potenzia la tua formazione
    • Programma educativo
    • Scale Up! Business Game
    • Visita Odoo
    Ottieni il software
    • Scarica
    • Versioni a confronto
    • Note di versione
    Collabora
    • Github
    • Forum
    • Eventi
    • Traduzioni
    • Diventa nostro partner
    • Servizi per partner
    • Registra la tua società di contabilità
    Ottieni servizi
    • Trova un partner
    • Trova un contabile
    • Incontra un esperto
    • Servizi di implementazione
    • Testimonianze dei clienti
    • Supporto
    • Aggiornamenti
    GitHub Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Richiedi una demo
  • Prezzi
  • Aiuto

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

  • CRM
  • e-Commerce
  • Contabilità
  • Magazzino
  • PoS
  • Progetti
  • MRP
All apps
È necessario essere registrati per interagire con la community.
Tutti gli articoli Persone Badge
Etichette (Mostra tutto)
odoo accounting v14 pos v15
Sul forum
È necessario essere registrati per interagire con la community.
Tutti gli articoli Persone Badge
Etichette (Mostra tutto)
odoo accounting v14 pos v15
Sul forum
Assistenza

Calculated fields in Search Filter, possible?

Iscriviti

Ricevi una notifica quando c'è un'attività per questo post

La domanda è stata contrassegnata
6 Risposte
34424 Visualizzazioni
Avatar
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
Avatar
Abbandona
Avatar
Annadurai
Risposta migliore

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
Avatar
Abbandona
Annadurai

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

Avatar
Roman Gsponer
Risposta migliore

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
Avatar
Abbandona
Avatar
Zeinab
Risposta migliore

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
Avatar
Abbandona
Saloua.sahnoune

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

Avatar
Ray Carnes
Risposta migliore

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
Avatar
Abbandona
Avatar
Esther Martín
Risposta migliore

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
Avatar
Abbandona
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.

Avatar
Damien Taylor
Autore Risposta migliore

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
Avatar
Abbandona
Andre de Kock

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

Ti stai godendo la conversazione? Non leggere soltanto, partecipa anche tu!

Crea un account oggi per scoprire funzionalità esclusive ed entrare a far parte della nostra fantastica community!

Registrati
Community
  • Tutorial
  • Documentazione
  • Forum
Open source
  • Scarica
  • Github
  • Runbot
  • Traduzioni
Servizi
  • Hosting Odoo.sh
  • Supporto
  • Aggiornamenti
  • Sviluppi personalizzati
  • Formazione
  • Trova un contabile
  • Trova un partner
  • Diventa nostro partner
Chi siamo
  • La nostra azienda
  • Branding
  • Contattaci
  • Lavora con noi
  • Eventi
  • Podcast
  • Blog
  • Clienti
  • Note legali • Privacy
  • Sicurezza
الْعَرَبيّة 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 è un gestionale di applicazioni aziendali open source pensato per coprire tutte le esigenze della tua azienda: CRM, Vendite, E-commerce, Magazzino, Produzione, Fatturazione elettronica, Project Management e molto altro.

Il punto di forza di Odoo è quello di offrire un ecosistema unico di app facili da usare, intuitive e completamente integrate tra loro.

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