Skip to Content
Odoo Menu
  • Prihlásiť sa
  • Vyskúšajte zadarmo
  • Aplikácie
    Financie
    • Účtovníctvo
    • Fakturácia
    • Výdavky
    • Tabuľka (BI)
    • Dokumenty
    • Podpis
    Predaj
    • CRM
    • Predaj
    • POS Shop
    • POS Restaurant
    • Manažment odberu
    • Požičovňa
    Webstránky
    • Tvorca webstránok
    • eShop
    • Blog
    • Fórum
    • Živý chat
    • eLearning
    Supply Chain
    • Sklad
    • Výroba
    • Správa životného cyklu produktu
    • Nákup
    • Údržba
    • Manažment kvality
    Ľudské zdroje
    • Zamestnanci
    • Nábor zamestnancov
    • Voľné dni
    • Hodnotenia
    • Odporúčania
    • Vozový park
    Marketing
    • Marketing sociálnych sietí
    • Email marketing
    • SMS marketing
    • Eventy
    • Marketingová automatizácia
    • Prieskumy
    Služby
    • Projektové riadenie
    • Pracovné výkazy
    • Práca v teréne
    • Helpdesk
    • Plánovanie
    • Schôdzky
    Produktivita
    • Tímová komunikácia
    • Schvalovania
    • IoT
    • VoIP
    • Znalosti
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Priemyselné odvetvia
    Retail
    • Book Store
    • Clothing Store
    • Furniture Store
    • Grocery Store
    • Hardware Store
    • Toy Store
    Food & Hospitality
    • Bar and Pub
    • Reštaurácia
    • Fast Food
    • Guest House
    • Beverage distributor
    • Hotel
    Reality
    • Real Estate Agency
    • Architecture Firm
    • Konštrukcia
    • Estate Managament
    • Gardening
    • Property Owner Association
    Poradenstvo
    • Accounting Firm
    • Odoo Partner
    • Marketing Agency
    • Law firm
    • Talent Acquisition
    • Audit & Certification
    Výroba
    • Textile
    • Metal
    • Furnitures
    • Jedlo
    • Brewery
    • Corporate Gifts
    Health & Fitness
    • Sports Club
    • Eyewear Store
    • Fitness Center
    • Wellness Practitioners
    • Pharmacy
    • Hair Salon
    Trades
    • Handyman
    • IT Hardware and Support
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Iní
    • Nonprofit Organization
    • Environmental Agency
    • Billboard Rental
    • Photography
    • Bike Leasing
    • Software Reseller
    Browse all Industries
  • Komunita
    Vzdelávanie
    • Tutoriály
    • Dokumentácia
    • Certifikácie
    • Školenie
    • Blog
    • Podcast
    Empower Education
    • Vzdelávací program
    • Scale Up! Business Game
    • Visit Odoo
    Softvér
    • Stiahnuť
    • Porovnanie Community a Enterprise vierzie
    • Releases
    Spolupráca
    • Github
    • Fórum
    • Eventy
    • Preklady
    • Staň sa partnerom
    • Services for Partners
    • Register your Accounting Firm
    Služby
    • Nájdite partnera
    • Nájdite účtovníka
    • Meet an advisor
    • Implementation Services
    • Zákaznícke referencie
    • Podpora
    • Upgrades
    ​Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Získajte demo
  • Cenník
  • Pomoc

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

  • CRM
  • e-Commerce
  • Účtovníctvo
  • Sklady
  • PoS
  • Projektové riadenie
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Tagy (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Tagy (View all)
odoo accounting v14 pos v15
About this forum
Pomoc

Calculated fields in Search Filter, possible?

Odoberať

Get notified when there's activity on this post

This question has been flagged
6 Replies
34411 Zobrazenia
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
Zrušiť
Avatar
Annadurai
Best Answer

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
Zrušiť
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
Best Answer

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
Zrušiť
Avatar
Zeinab
Best Answer

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
Zrušiť
Saloua.sahnoune

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

Avatar
Ray Carnes
Best Answer

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
Zrušiť
Avatar
Esther Martín
Best Answer

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
Zrušiť
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
Autor Best Answer

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
Zrušiť
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!

Registrácia
Komunita
  • Tutoriály
  • Dokumentácia
  • Fórum
Open Source
  • Stiahnuť
  • Github
  • Runbot
  • Preklady
Služby
  • Odoo.sh hosting
  • Podpora
  • Vyššia verzia
  • Custom Developments
  • Vzdelávanie
  • Nájdite účtovníka
  • Nájdite partnera
  • Staň sa partnerom
O nás
  • Naša spoločnosť
  • Majetok značky
  • Kontaktujte nás
  • Pracovné ponuky
  • Eventy
  • Podcast
  • Blog
  • Zákazníci
  • Právne dokumenty • Súkromie
  • Bezpečnosť
الْعَرَبيّة 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 je sada podnikových aplikácií s otvoreným zdrojovým kódom, ktoré pokrývajú všetky potreby vašej spoločnosti: CRM, e-shop, účtovníctvo, skladové hospodárstvo, miesto predaja, projektový manažment atď.

Odoo prináša vysokú pridanú hodnotu v jednoduchom použití a súčasne plne integrovanými biznis aplikáciami.

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