Overslaan naar inhoud
Odoo Menu
  • Aanmelden
  • Probeer het gratis
  • Apps
    Financiën
    • Boekhouding
    • Facturatie
    • Onkosten
    • Spreadsheet (BI)
    • Documenten
    • Ondertekenen
    Verkoop
    • CRM
    • Verkoop
    • Kassasysteem winkel
    • Kassasysteem Restaurant
    • Abonnementen
    • Verhuur
    Websites
    • Websitebouwer
    • E-commerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Bevoorradingsketen
    • Voorraad
    • Productie
    • PLM
    • Inkoop
    • Onderhoud
    • Kwaliteit
    Personeelsbeheer
    • Werknemers
    • Werving & Selectie
    • Verlof
    • Evaluaties
    • Aanbevelingen
    • Wagenpark
    Marketing
    • Social media Marketing
    • E-mailmarketing
    • SMS Marketing
    • Evenementen
    • Marketingautomatisering
    • Enquêtes
    Diensten
    • Project
    • Urenstaten
    • Buitendienst
    • Helpdesk
    • Planning
    • Afspraken
    Productiviteit
    • Chat
    • Goedkeuringen
    • IoT
    • VoIP
    • Kennis
    • WhatsApp
    Apps van derden Odoo Studio Odoo Cloud Platform
  • Bedrijfstakken
    Detailhandel
    • Boekhandel
    • kledingwinkel
    • Meubelzaak
    • Supermarkt
    • Bouwmarkt
    • Speelgoedwinkel
    Food & Hospitality
    • Bar en Pub
    • Restaurant
    • Fastfood
    • Gastenverblijf
    • Drankenhandelaar
    • Hotel
    Vastgoed
    • Makelaarskantoor
    • Architectenbureau
    • Bouw
    • Vastgoedbeheer
    • Tuinieren
    • Vereniging van eigenaren
    Consulting
    • Accountantskantoor
    • Odoo Partner
    • Marketingbureau
    • Advocatenkantoor
    • Talentenwerving
    • Audit & Certificering
    Productie
    • Textiel
    • Metaal
    • Meubels
    • Eten
    • Brewery
    • Relatiegeschenken
    Gezondheid & Fitness
    • Sportclub
    • Opticien
    • Fitnesscentrum
    • Wellness-medewerkers
    • Apotheek
    • Kapper
    Trades
    • Klusjesman
    • IT-hardware & support
    • Zonne-energiesystemen
    • Schoenmaker
    • Schoonmaakdiensten
    • HVAC-diensten
    Andere
    • Non-profit organisatie
    • Milieuagentschap
    • Verhuur van Billboards
    • Fotograaf
    • Fietsleasing
    • Softwareverkoper
    Browse all Industries
  • Community
    Leren
    • Tutorials
    • Documentatie
    • Certificeringen
    • Training
    • Blog
    • Podcast
    Versterk het onderwijs
    • Onderwijs- programma
    • Scale Up! Business Game
    • Bezoek Odoo
    Download de Software
    • Downloaden
    • Vergelijk edities
    • Releases
    Werk samen
    • Github
    • Forum
    • Evenementen
    • Vertalingen
    • Word een Partner
    • Services for Partners
    • Registreer je accountantskantoor
    Diensten
    • Vind een partner
    • Vind een boekhouder
    • Een adviseur ontmoeten
    • Implementatiediensten
    • Klantreferenties
    • Ondersteuning
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Vraag een demo aan
  • Prijzen
  • Help

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

  • CRM
  • e-Commerce
  • Boekhouding
  • Voorraad
  • PoS
  • Project
  • MRP
All apps
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Alle posts Personen Badges
Labels (Bekijk alle)
odoo accounting v14 pos v15
Over dit forum
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Alle posts Personen Badges
Labels (Bekijk alle)
odoo accounting v14 pos v15
Over dit forum
Help

Search with functional fields

Inschrijven

Ontvang een bericht wanneer er activiteit is op deze post

Deze vraag is gerapporteerd
filtersearch
4 Antwoorden
21738 Weergaven
Avatar
Bruno Cascio

How to search with functional fields?

my code

'calculate_next_visit' : fields.function( 
     __get_next_visit,
    method=True,
    type='char',
    store=True,
    string="Calculo de próxima visita"),

 def __get_next_visit(self, cr, uid, obj, name, args, context):
      print 'something'
      res = {}
      for v in self.browse(cr, uid, obj):
         diagnosis = map(lambda x:x.upper(),v.diagnosis)
         if 'PAP' in diagnosis or 'P.A.P' in diagnosis:
           # more code....
            res[v.id] = True
      return res

and my view:

<record id="search_visit_filter" model="ir.ui.view">
      <field name="name">Visitas</field>
      <field name="model">visit</field>
      <field name="arch" type="xml">
        <search string="Search xxx">
            <filter domain="[('calculate_next_visit','=',True)]" string="Visitas Próximas a la fecha"/>
        </search>
      </field>
    </record>

When select filter, never print "something"

Somebody Help me?

THE SOLUTION

'calculate_next_visit' : fields.function(
         _next_visit,
         fnct_search=_search_next_visit,
         method=True, 
         type='char', 
         multi=True,
         string="Calculo de próxima visita", 
      ),

set fnct_search parameter, and implement that.

def _search_next_visit(self, cr, uid, obj, name, args, context=None):
      res = []
      ids = obj.search(cr,uid,[]) # ids of visits
      for v in self.browse(cr, uid, ids): # foreach visit
         diags = [d.name.upper() for d in v.diagnosis]
         if "PAP" in diags:
            res.append(v.id)
      return [('id','in',res)]

important return type of fnct_search

and my search view...

<group expand="0" string="Agrupar por...">
            <filter string="Próximas Visitas" domain="[('calculate_next_visit','=',True)]" context="{'group_by':'next_visit'}" />
</group>

check documentation for fnct_search functions

1
Avatar
Annuleer
Ajeng Shilvie

@ Bruno , i have the same problem as you . You already found the answer right ? did you change __get_next_visit method as well ?

Avatar
Roc cheng
Beste antwoord

Hi, It looks like you just want testing whether the __get_next_visit on working.. but on serach view,When select filter,this way won't trigger the function. because the object never changed.

4
Avatar
Annuleer
Bruno Cascio
Auteur

Thanks! There is the possibility of implementing a filter to only such rows that meet a condition such that a date approximates the current date?

Avatar
Dhinesh
Beste antwoord

Hi, Functional fields get triggered at the time of saving the record. If u want to trigger at the time of loading try to give in _defaults.

3
Avatar
Annuleer
Bruno Cascio
Auteur

I tried a default field, and I was not successful. Could you explain please?

Avatar
xingtongjie
Beste antwoord

let  function field `s store parameter equal True

0
Avatar
Annuleer
Avatar
Deepa Venkatesh
Beste antwoord

Hi...

Firstly, your data to that field is not correct, I mean you have defined functional field for "Char" whereas your function is returning True which is of type "Boolean"... so loook into your code again...

Then coming to search criteria, A functional field is of two type.. One having a "store" property and one without it..

1. when store is set True: then the functional field and its value will be saved in the database, which will act just like other physical fields, so you can specify it in search without any issue..

2. when store is not set: then the functional field will be like evalution field, meaning value for it will be evaluated/computed only when it is triggered... henceforth one cannot use it in search view, as the field and its data are not stored in db... So in order to search, you should write "fnct_search" property to your function field and define it accordingly...

Check this link for more details: Function Fields

You can find many examples in addons.

Hope this will help you.

 

0
Avatar
Annuleer
Geniet je van het gesprek? Blijf niet alleen lezen, doe ook mee!

Maak vandaag nog een account aan om te profiteren van exclusieve functies en deel uit te maken van onze geweldige community!

Aanmelden
Gerelateerde posts Antwoorden Weergaven Activiteit
how can i create a filter that uses the "and" condition
filter search
Avatar
Avatar
Avatar
2
nov. 23
3932
How to save a filter with today value from context Opgelost
filter search
Avatar
Avatar
Avatar
Avatar
Avatar
7
apr. 21
21554
filter with related model field Opgelost
filter search
Avatar
1
okt. 20
5528
change search filter Opgelost
filter search
Avatar
Avatar
2
nov. 16
4743
How to set a new search filter?
filter search
Avatar
Avatar
1
mrt. 15
14254
Community
  • Tutorials
  • Documentatie
  • Forum
Open Source
  • Downloaden
  • Github
  • Runbot
  • Vertalingen
Diensten
  • Odoo.sh Hosting
  • Ondersteuning
  • Upgrade
  • Gepersonaliseerde ontwikkelingen
  • Onderwijs
  • Vind een boekhouder
  • Vind een partner
  • Word een Partner
Over ons
  • Ons bedrijf
  • Merkelementen
  • Neem contact met ons op
  • Vacatures
  • Evenementen
  • Podcast
  • Blog
  • Klanten
  • Juridisch • Privacy
  • Beveiliging
الْعَرَبيّة 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 is een suite van open source zakelijke apps die aan al je bedrijfsbehoeften voldoet: CRM, E-commerce, boekhouding, inventaris, kassasysteem, projectbeheer, enz.

Odoo's unieke waardepropositie is om tegelijkertijd zeer gebruiksvriendelijk en volledig geïntegreerd te zijn.

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