İçereği Atla
Odoo Menü
  • Portal
  • Ücretsiz deneyin
  • Uygulamalar
    Finans
    • Muhasebe
    • Faturalama
    • Masraf Yönetimi
    • Elektronik Çizelge (BI)
    • Belgeler
    • İmza
    Satış
    • Müşteri İlişkileri Yönetimi (CRM)
    • Satış
    • Satış Noktası Mağaza
    • Satış Noktası Restoran
    • Abonelikler
    • Kiralama
    Web Sitesi
    • Web Sitesi Oluşturucu
    • eTicaret
    • Blog
    • Forum
    • Canlı Sohbet
    • eÖğrenme
    Tedarik Zinciri
    • Envanter
    • Üretim
    • Ürün Yaşam Döngüsü Yönetimi
    • Satın Alma
    • Bakım
    • Kalite
    İnsan Kaynakları
    • Çalışanlar
    • İşe Alım
    • İzin
    • Değerlendirme
    • Referans
    • Filo Yönetimi
    Pazarlama
    • Sosyal Medyada Pazarlama
    • E-posta ile Pazarlama
    • SMS ile Pazarlama
    • Etkinlikler
    • Pazarlama Otomasyonu
    • Anket
    Hizmetler
    • Proje Yönetimi
    • Çalışma Çizelgeleri
    • Saha Hizmeti
    • Yardım Masası
    • Planlama
    • Randevular
    Verimlilik
    • Sohbet
    • Onay
    • Nesnelerin İnterneti
    • VoIP
    • Bilgi Bankası
    • WhatsApp
    Üçüncü taraf uygulamalar Odoo Stüdyo Odoo Bulut Platformu
  • Sektörler
    Perakende satış
    • Kitapçı
    • Giyim Mağazası
    • Mobilya Mağazası
    • Gıda Marketi
    • Hırdavat Dükkanı
    • Oyuncak Dükkanı
    Gıda ve Konaklama
    • Bar ve Pub
    • Restoran
    • Fast Food Restoranı
    • Konuk Evi
    • İçecek Distribütörü
    • Otel
    Gayrimenkul
    • Emlak Acentesi
    • Mimarlık Firması
    • İnşaat
    • Emlak Yönetimi
    • Bahçe Tasarımı
    • Mülk Sahipleri Derneği
    Uzmanlık
    • Muhasebe Firması
    • Odoo Partner
    • Pazarlama Ajansı
    • Hukuk Firması
    • Yetenek Kazanımı
    • Denetim ve Belgelendirme
    Üretim
    • Tekstil
    • Metal
    • Mobilyalar
    • Gıda
    • Bira fabrikası
    • Kurumsal Hediye
    Sağlık ve Spor
    • Spor Kulübü
    • Optik Mağazası
    • Fitness Merkezi
    • Sağlıklı Yaşam Merkezi
    • Eczane
    • Kuaför Salonu
    Ticaret
    • Tamirci
    • BT Donanım & Destek
    • Güneş Enerjisi Sistemleri
    • Ayakkabı İmalatçısı
    • Temizlik Hizmetleri
    • HVAC Hizmetleri
    Diğerleri
    • Kar Amacı Gütmeyen Kuruluş
    • Çevre Ajansı
    • Reklam Panosu Kiralama
    • Fotoğrafçılık
    • Bisiklet Kiralama
    • Yazılım Bayisi
    Tüm Sektörlere Göz Atın
  • Topluluk
    Öğrenim
    • Eğitim Araçları
    • Dokümantasyon
    • Sertifikasyonlar
    • Eğitim Etkinlikleri
    • Blog
    • Podcast
    Eğitim ve Gelişim
    • Eğitim Programı
    • Scale Up! İşletme Oyunu
    • Odoo'yu Ziyaret Edin
    Yazılım
    • İndirin
    • Sürümleri Kıyaslayın
    • Sürümler
    İş Birliği
    • Github
    • Forum
    • Etkinlikler
    • Çeviriler
    • Partner Olun
    • Partnerler için Hizmetler
    • Muhasebe Firmanızı Kaydettirin
    Hizmetler
    • Partner Bulun
    • Muhasebeci Bulun
    • Bir danışmanla görüşün
    • Kurulum Hizmetleri
    • Müşteri Referansları
    • Destek
    • Sürüm Yükseltme
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Demo randevusu alın
  • Fiyatlandırma
  • Yardım

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

  • Müşteri İlişkileri Yönetimi
  • e-Commerce
  • Muhasebe
  • Envanter
  • PoS
  • Proje Yönetimi
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Etiketler (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Etiketler (View all)
odoo accounting v14 pos v15
About this forum
Yardım

Search with functional fields

Abone Ol

Get notified when there's activity on this post

Bu soru işaretlendi
filtersearch
4 Cevaplar
21741 Görünümler
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
Vazgeç
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
En İyi Yanıt

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
Vazgeç
Bruno Cascio
Üretici

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
En İyi Yanıt

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
Vazgeç
Bruno Cascio
Üretici

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

Avatar
xingtongjie
En İyi Yanıt

let  function field `s store parameter equal True

0
Avatar
Vazgeç
Avatar
Deepa Venkatesh
En İyi Yanıt

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
Vazgeç
Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Üye Ol
İlgili Gönderiler Cevaplar Görünümler Aktivite
how can i create a filter that uses the "and" condition
filter search
Avatar
Avatar
Avatar
2
Kas 23
3933
How to save a filter with today value from context Çözüldü
filter search
Avatar
Avatar
Avatar
Avatar
Avatar
7
Nis 21
21567
filter with related model field Çözüldü
filter search
Avatar
1
Eki 20
5532
change search filter Çözüldü
filter search
Avatar
Avatar
2
Kas 16
4744
How to set a new search filter?
filter search
Avatar
Avatar
1
Mar 15
14257
Topluluk
  • Eğitim Araçları
  • Dokümantasyon
  • Forum
Açık Kaynak
  • İndirin
  • Github
  • Runbot
  • Çeviriler
Hizmetler
  • Odoo.sh Hosting
  • Destek
  • Sürüm Yükseltme
  • Özel Geliştirmeler
  • Eğitim
  • Muhasebeci Bulun
  • Partner Bulun
  • Partner Olun
Hakkında
  • Şirketimiz
  • Pazarlama Gereçleri
  • İletişim
  • Kariyer
  • Etkinlikler
  • Podcast
  • Blog
  • Müşteriler
  • Hukuki • Gizlilik
  • Güvenlik
الْعَرَبيّة 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, müşteri ilişkileri yönetimi, eTicaret, muhasebe, envanter, satış noktası, proje yönetimi gibi şirketinizin tüm ihtiyaçlarını karşılayan bir açık kaynak işletme uygulamaları paketidir.

Odoo’nun eşsiz değer önermesi, aynı anda hem kullanımının çok kolay olup hem de tamamen entegre olmasıdır.

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