์ฝ˜ํ…์ธ ๋กœ ๊ฑด๋„ˆ๋›ฐ๊ธฐ
Odoo ๋ฉ”๋‰ด
  • ๋กœ๊ทธ์ธ
  • ๋ฌด๋ฃŒ ์ฒดํ—˜ํ•˜๊ธฐ
  • ์•ฑ
    ์žฌ๋ฌด ๊ด€๋ฆฌ
    • ํšŒ๊ณ„
    • ์ฒญ๊ตฌ์„œ ๊ด€๋ฆฌ
    • ๋น„์šฉ ๊ด€๋ฆฌ
    • ์Šคํ”„๋ ˆ๋“œ์‹œํŠธ (BI)
    • ๋ฌธ์„œ
    • ์ „์ž ์„œ๋ช…
    ํŒ๋งค
    • CRM
    • ํŒ๋งค
    • POS ์Šคํ† ์–ด
    • POS ๋ ˆ์Šคํ† ๋ž‘
    • ๊ตฌ๋…
    • ๋ Œํƒˆ
    ์›น์‚ฌ์ดํŠธ
    • ์›น์‚ฌ์ดํŠธ ๋นŒ๋”
    • ์ด์ปค๋จธ์Šค
    • ๋ธ”๋กœ๊ทธ
    • ํฌ๋Ÿผ
    • ์‹ค์‹œ๊ฐ„ ์ฑ„ํŒ…
    • ์˜จ๋ผ์ธ ํ•™์Šต ๊ด€๋ฆฌ
    ๊ณต๊ธ‰๋ง
    • ์žฌ๊ณ  ๊ด€๋ฆฌ
    • ์ œ์กฐ ๊ด€๋ฆฌ
    • ์ œํ’ˆ ์ˆ˜๋ช…์ฃผ๊ธฐ ๊ด€๋ฆฌ (PLM)
    • ๋งค์ž…
    • ์œ ์ง€๊ด€๋ฆฌ
    • ํ’ˆ์งˆ
    ์ธ์ ์ž์› ๊ด€๋ฆฌ
    • ์ง์›
    • ์ฑ„์šฉ
    • ํœด๊ฐ€ ๊ด€๋ฆฌ
    • ์ธ์‚ฌ ํ‰๊ฐ€
    • ์ธ์žฌ ์ถ”์ฒœ
    • ์ฐจ๋Ÿ‰ ๊ด€๋ฆฌ
    ๋งˆ์ผ€ํŒ…
    • ์†Œ์…œ ๋งˆ์ผ€ํŒ…
    • ์ด๋ฉ”์ผ ๋งˆ์ผ€ํŒ…
    • SMS ๋งˆ์ผ€ํŒ…
    • ํ–‰์‚ฌ
    • ๋งˆ์ผ€ํŒ… ์ž๋™ํ™”
    • ์„ค๋ฌธ ์กฐ์‚ฌ
    ์„œ๋น„์Šค
    • ํ”„๋กœ์ ํŠธ
    • ์ž‘์—… ๊ธฐ๋ก
    • ํ˜„์žฅ ์„œ๋น„์Šค
    • ํ—ฌํ”„๋ฐ์Šคํฌ
    • ์ผ์ • ๊ด€๋ฆฌ
    • ์ผ์ • ์˜ˆ์•ฝ
    ์ƒ์‚ฐ์„ฑ
    • ๋ฉ”์ผ ๋ฐ ์ฑ„ํŒ…
    • ์ „์ž ๊ฒฐ์žฌ
    • IoT
    • VoIP
    • ์ง€์‹ ์„ผํ„ฐ
    • WhatsApp
    ํƒ€์‚ฌ ์•ฑ Odoo ์ŠคํŠœ๋””์˜ค Odoo ํด๋ผ์šฐ๋“œ ํ”Œ๋žซํผ
  • ์ธ๋”์ŠคํŠธ๋ฆฌ
    ๋ฆฌํ…Œ์ผ
    • ์„œ์ 
    • ์˜๋ฅ˜ ๋งค์žฅ
    • ๊ฐ€๊ตฌ์ 
    • ์‹๋ฃŒํ’ˆ์ 
    • ์ฒ ๋ฌผ์ 
    • ์žฅ๋‚œ๊ฐ ๊ฐ€๊ฒŒ
    ์‹์Œ๋ฃŒ & ์ˆ™๋ฐ•์—…
    • ๋ฐ” & ํŽ
    • ๋ ˆ์Šคํ† ๋ž‘
    • ํŒจ์ŠคํŠธํ‘ธ๋“œ
    • ๊ฒŒ์ŠคํŠธ ํ•˜์šฐ์Šค
    • ์Œ๋ฃŒ ์œ ํ†ต์—…์ฒด
    • ํ˜ธํ…”
    ๋ถ€๋™์‚ฐ
    • ๋ถ€๋™์‚ฐ ์ค‘๊ฐœ์—…์ฒด
    • ๊ฑด์ถ• ํšŒ์‚ฌ
    • ๊ฑด์„ค
    • ๋ถ€๋™์‚ฐ ๊ด€๋ฆฌ
    • ๊ฐ€๋“œ๋‹
    • ๋ถ€๋™์‚ฐ ์†Œ์œ ์ž ํ˜‘ํšŒ
    ์ปจ์„คํŒ…
    • ํšŒ๊ณ„ ๋ฒ•์ธ
    • Odoo ํŒŒํŠธ๋„ˆ
    • ๋งˆ์ผ€ํŒ… ๋Œ€ํ–‰์‚ฌ
    • ๋ฒ•๋ฅ  ์‚ฌ๋ฌด์†Œ
    • ์ธ์žฌ ์˜์ž…
    • ๊ฐ์‚ฌ ๋ฐ ์ธ์ฆ
    ์ œ์กฐ ๊ด€๋ฆฌ
    • ํ…์Šคํƒ€์ผ
    • ๋ฉ”ํƒˆ
    • ๊ฐ€๊ตฌ
    • ํ‘ธ๋“œ
    • ์–‘์กฐ์žฅ
    • ๊ธฐ์—…์šฉ ์„ ๋ฌผ
    ๊ฑด๊ฐ• & ํ”ผํŠธ๋‹ˆ์Šค
    • ์Šคํฌ์ธ  ํด๋Ÿฝ
    • ์•ˆ๊ฒฝ์ 
    • ํ”ผํŠธ๋‹ˆ์Šค ์„ผํ„ฐ
    • ์›ฐ๋‹ˆ์Šค ์ „๋ฌธ๊ฐ€
    • ์•ฝ๊ตญ
    • ๋ฏธ์šฉ์‹ค
    ์‚ฌ์—…
    • ํ•ธ๋””๋งจ
    • IT ํ•˜๋“œ์›จ์–ด ๋ฐ ์ง€์› ์„œ๋น„์Šค
    • ํƒœ์–‘ ์—๋„ˆ์ง€ ์‹œ์Šคํ…œ
    • ์ œํ™”์—…์ฒด
    • ํด๋ฆฌ๋‹ ์„œ๋น„์Šค
    • HVAC ์„œ๋น„์Šค
    ๊ธฐํƒ€
    • ๋น„์˜๋ฆฌ ๋‹จ์ฒด
    • ํ™˜๊ฒฝ ์—์ด์ „์‹œ
    • ๊ด‘๊ณ ํŒ ์ž„๋Œ€
    • ์‚ฌ์ง„
    • ์ž์ „๊ฑฐ ์ž„๋Œ€
    • ์†Œํ”„ํŠธ์›จ์–ด ๋ฆฌ์…€๋Ÿฌ
    ์ „์ฒด ์ธ๋”์ŠคํŠธ๋ฆฌ ์ฐพ์•„๋ณด๊ธฐ
  • ์ปค๋ฎค๋‹ˆํ‹ฐ
    ํ•™์Šต
    • ํŠœํ† ๋ฆฌ์–ผ
    • ๋ฌธ์„œ
    • ์ธ์ฆ
    • ํ›ˆ๋ จ
    • ๋ธ”๋กœ๊ทธ
    • ํŒŸ์บ์ŠคํŠธ
    ๊ต์œก ์—ญ๋Ÿ‰ ๊ฐ•ํ™”
    • ๊ต์œก ํ”„๋กœ๊ทธ๋žจ
    • Scale-Up! ๊ฒฝ์˜๊ด€๋ฆฌ ๊ฒŒ์ž„
    • Odoo์— ๋ฐฉ๋ฌธํ•ด๋ณด์„ธ์š”
    ์†Œํ”„ํŠธ์›จ์–ด ์‹ ์ฒญ
    • ๋‹ค์šด๋กœ๋“œ
    • ๋ฒ„์ „ ์‚ดํŽด๋ณด๊ธฐ
    • ๋ฆด๋ฆฌ์ฆˆ ๋‚ด์—ญ
    ํ˜‘์—…
    • Github
    • ํฌ๋Ÿผ
    • ํ–‰์‚ฌ
    • ๋ฒˆ์—ญ
    • ํŒŒํŠธ๋„ˆ ๋“ฑ๋ก
    • ํŒŒํŠธ๋„ˆ ๋Œ€์ƒ ์„œ๋น„์Šค
    • ํšŒ๊ณ„ ๋ฒ•์ธ ์ •๋ณด ๋“ฑ๋ก
    ์„œ๋น„์Šค ์‹ ์ฒญ
    • ํŒŒํŠธ๋„ˆ ๊ฒ€์ƒ‰
    • ํšŒ๊ณ„์‚ฌ ๊ฒ€์ƒ‰
    • ์ „๋ฌธ ์ƒ๋‹ด ์˜ˆ์•ฝ
    • ๊ตฌํ˜„ ์„œ๋น„์Šค
    • ๊ณ ๊ฐ ์ •๋ณด
    • ๊ณ ๊ฐ ์ง€์›
    • ์—…๊ทธ๋ ˆ์ด๋“œ
    Github ์œ ํŠœ๋ธŒ ํŠธ์œ„ํ„ฐ ๋งํฌ๋“œ์ธ ์ธ์Šคํƒ€๊ทธ๋žจ ํŽ˜์ด์Šค๋ถ ์Šคํฌํ‹ฐํŒŒ์ด
    +1 (650) 691-3277
    ๋ฐ๋ชจ ์˜ˆ์•ฝํ•˜๊ธฐ
  • ์š”๊ธˆ์ œ
  • ๊ณ ๊ฐ ์ง€์›

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

  • CRM
  • e-Commerce
  • ํšŒ๊ณ„
  • ์žฌ๊ณ  ๊ด€๋ฆฌ
  • PoS
  • ํ”„๋กœ์ ํŠธ
  • MRP
All apps
์ปค๋ฎค๋‹ˆํ‹ฐ์— ์ฐธ์—ฌํ•˜๋ ค๋ฉด ํšŒ์› ๊ฐ€์ž…์„ ํ•˜์‹œ๊ธฐ ๋ฐ”๋ž๋‹ˆ๋‹ค.
๋ชจ๋“  ๊ฒŒ์‹œ๋ฌผ ์‚ฌ์šฉ์ž ๋ฐฐ์ง€
ํƒœ๊ทธ (๋ชจ๋‘ ๋ณด๊ธฐ)
odoo accounting v14 pos v15
๊ฒŒ์‹œํŒ ์ •๋ณด
์ปค๋ฎค๋‹ˆํ‹ฐ์— ์ฐธ์—ฌํ•˜๋ ค๋ฉด ํšŒ์› ๊ฐ€์ž…์„ ํ•˜์‹œ๊ธฐ ๋ฐ”๋ž๋‹ˆ๋‹ค.
๋ชจ๋“  ๊ฒŒ์‹œ๋ฌผ ์‚ฌ์šฉ์ž ๋ฐฐ์ง€
ํƒœ๊ทธ (๋ชจ๋‘ ๋ณด๊ธฐ)
odoo accounting v14 pos v15
๊ฒŒ์‹œํŒ ์ •๋ณด
๋„์›€๋ง

๐Ÿ” Odoo 17 : How to Search Compute Fields Without store=True in Python (Backend)?

๊ตฌ๋…

์ด ๊ฒŒ์‹œ๋ฌผ์— ํ™œ๋™์ด ์žˆ์œผ๋ฉด ์•Œ๋ฆผ ๋ฐ›๊ธฐ

์‹ ๊ณ ๋œ ์งˆ๋ฌธ์ž…๋‹ˆ๋‹ค
computed-fieldsodoo-developmentodoo-customization
1 ํšŒ์‹ 
2470 ํ™”๋ฉด
์•„๋ฐ”ํƒ€
Rushik Pitroda
โœ… Problem Statement (with Code Example)

from odoo import models, fields, api

import logging

_logger = logging.getLogger(__name__)


class ComputeDemo(models.Model):

ย  ย  _name = 'compute.demo'

ย  ย  _description = 'Compute Demo Model'


ย  ย  age = fields.Integer(string="Age")

ย  ย  compute_age = fields.Integer(string="Compute Age", compute="_compute_based_on_age", store=False)


ย  ย  @api.depends('age')

ย  ย  def _compute_based_on_age(self):

ย  ย  ย  ย  for rec in self:

ย  ย  ย  ย  ย  ย  rec.compute_age = rec.age


ย  ย  def click_me(self):

ย  ย  ย  ย  data = self.search([('compute_age', '=', 10)])

ย  ย  ย  ย  if data:

ย  ย  ย  ย  ย  ย  _logger.info("Search Data Found: %s", data)

ย  ย  ย  ย  else:

ย  ย  ย  ย  ย  ย  _logger.info("Search Data Not Found: %s", data)

Log :ย Non-stored field compute.demo.compute_age cannot be searched.


Can anyone guide me ?

Any help would be highly appreciated ๐Ÿ™

Thanks in advance!

1
์•„๋ฐ”ํƒ€
์ทจ์†Œ
์•„๋ฐ”ํƒ€
Christoph Farnleitner
๋ฒ ์ŠคํŠธ ๋‹ต๋ณ€

Note: Since your example code lacks meaning, the answer may as well. This is because in the given scenario you may as well just define a related field rather than a computed one.


In general, the reason why you can not search for a non-stored field using ORM methods directly is the fact that ultimately a search (domain) is converted to an actual SQLย SELECT statementย -ย and this statement, since it's executed on the database, can only search for information actually stored in the database.
In return this means that whatever computation happens for any given computed field, would needย happen on-the-fly while searching - which couldย pretty quickly result in poor performance.


To search for values in a computed field you can define a search method used for that field. See also 'searching on a computed field' in https://www.odoo.com/documentation/17.0/developer/reference/backend/orm.html#computed-fields.


So, in your example this would look like this:

    age = fields.Integer(string='Age')
compute_age = fields.Integer(string='Compute Age',
compute='_compute_compute_age',
search='_search_compute_age', # defines 'how' to search
store=False)

ย  ย  def _search_compute_age(self, operator, value):
# According to the compute method, there is a direct link between
# 'age' and 'compute_age', thus you can search for 'age' directly.
#ย  In case there is a processing happening of 'age', you will have
# to reflect this in the 'value' variable and reverse the logic.
ย  ย  ย  ย  # As an example:
# if _compute_compute_age() does something like 'compute_age = age * 10',
# you will have to, in return, search for 'compute_age / 10' as
# this is your 'age' actually stored.
ย  ย  ย  ย  return [('age', operator, value)]

ย  ย  @api.depends('age')
ย  ย  def _compute_compute_age(self):
ย  ย  ย  ย  for rec in self:
ย  ย  ย  ย  ย  ย  rec.compute_age = rec.age

ย  ย  def action_search_compute_age(self):
ย  ย  ย  ย  data = self.search([('compute_age', '=', 10)])
ย  ย  ย  ย  if data:
ย  ย  ย  ย  ย  ย  _logger.info('Search Data Found: %s', data)
ย  ย  ย  ย  else:
ย  ย  ย  ย  ย  ย  _logger.info('Search Data Not Found: %s', data)


While this works, you may still reconsider your approach and whether this field really can not be stored in the database, especially since it is needed for search operations.

The heavier the computation gets, the heavier the load on the database will be every time this field is to be rendered (and this gets multiplied byย the number of records shown in a list view for example).

0
์•„๋ฐ”ํƒ€
์ทจ์†Œ
Rushik Pitroda
์ž‘์„ฑ์ž

Thank you so much for the detailed explanation!
Really appreciate your time and guidance! ๐Ÿ˜Š

ํ† ๋ก ์ด ์žฌ๋ฏธ์žˆ์œผ์‹ ๊ฐ€์š”? ์ง์ ‘ ์ฐธ์—ฌํ•ด๋ณด์„ธ์š”!

์ง€๊ธˆ ๋ฐ”๋กœ ๊ฐ€์ž…ํ•˜์—ฌ ๋…์  ์„œ๋น„์Šค๋ฅผ ์ด์šฉํ•ด๋ณด๊ณ  ํŠน๋ณ„ํ•œ ์ปค๋ฎค๋‹ˆํ‹ฐ์™€ ์†Œํ†ตํ•˜์„ธ์š”!

๊ฐ€์ž…
๊ด€๋ จ ๊ฒŒ์‹œ๋ฌผ ๋‹ต๊ธ€ ํ™”๋ฉด ํ™œ๋™
How to Set Decimal Accuracy for a Custom Float Field
odoo18 odoo17 odoo-development odoo-customization
์•„๋ฐ”ํƒ€
์•„๋ฐ”ํƒ€
1
6์›” 25
2187
Cursor closed error during large CSV import via cron job in Odoo.sh
database cronjob odoo18 odoo-development odoo-customization
์•„๋ฐ”ํƒ€
์•„๋ฐ”ํƒ€
1
6์›” 25
2339
ValueError: forbidden opcode(s) in 'lambda': STORE_ATTR
computed-fields
์•„๋ฐ”ํƒ€
์•„๋ฐ”ํƒ€
1
6์›” 25
17287
Make stored compute filed recompute after changing it logic but not depedencies.
computed-fields
์•„๋ฐ”ํƒ€
์•„๋ฐ”ํƒ€
์•„๋ฐ”ํƒ€
์•„๋ฐ”ํƒ€
3
4์›” 25
7901
Compute Fields ํ•ด๊ฒฐ ์™„๋ฃŒ
computed-fields
์•„๋ฐ”ํƒ€
์•„๋ฐ”ํƒ€
2
7์›” 24
9490
์ปค๋ฎค๋‹ˆํ‹ฐ
  • ํŠœํ† ๋ฆฌ์–ผ
  • ๋ฌธ์„œ
  • ํฌ๋Ÿผ
์˜คํ”ˆ ์†Œ์Šค
  • ๋‹ค์šด๋กœ๋“œ
  • Github
  • Runbot
  • ๋ฒˆ์—ญ
์„œ๋น„์Šค
  • Odoo.sh ํ˜ธ์ŠคํŒ…
  • ๊ณ ๊ฐ ์ง€์›
  • ์—…๊ทธ๋ ˆ์ด๋“œ
  • ๋งž์ถค ๊ฐœ๋ฐœ
  • ํ•™์Šต
  • ํšŒ๊ณ„์‚ฌ ๊ฒ€์ƒ‰
  • ํŒŒํŠธ๋„ˆ ๊ฒ€์ƒ‰
  • ํŒŒํŠธ๋„ˆ ๋“ฑ๋ก
ํšŒ์‚ฌ ์†Œ๊ฐœ
  • ํšŒ์‚ฌ ์†Œ๊ฐœ
  • ๋ธŒ๋žœ๋“œ ์ž์‚ฐ
  • ์ƒ๋‹ด ๋ฌธ์˜
  • ์ธ์žฌ ์ฑ„์šฉ
  • ํ–‰์‚ฌ
  • ํŒŸ์บ์ŠคํŠธ
  • ๋ธ”๋กœ๊ทธ
  • ๊ณ ๊ฐ ์‚ฌ๋ก€
  • ๋ฒ•์ ๊ณ ์ง€ โ€ข ๊ฐœ์ธ์ •๋ณด
  • ๋ณด์•ˆ
ุงู„ู’ุนูŽุฑูŽุจูŠู‘ุฉ 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๋Š” CRM, ์ด์ปค๋จธ์Šค, ํšŒ๊ณ„, ์žฌ๊ณ , POS, ํ”„๋กœ์ ํŠธ ๊ด€๋ฆฌ ๋“ฑ ๊ธฐ์—…์˜ ๋ชจ๋“  ์š”๊ตฌ ์‚ฌํ•ญ์„ ์ถฉ์กฑํ•˜๋„๋ก ์„ค๊ณ„๋œ ์˜คํ”ˆ ์†Œ์Šค ๊ธฐ๋ฐ˜์˜ ํ†ตํ•ฉ ๋น„์ฆˆ๋‹ˆ์Šค ์•ฑ ์ œํ’ˆ๊ตฐ์ž…๋‹ˆ๋‹ค.

Odoo์˜ ๊ฐ„ํŽธํ•œ UI์™€ ์™„๋ฒฝํ•˜๊ฒŒ ํ†ตํ•ฉ๋œ ๊ธฐ๋Šฅ์„ ์ง์ ‘ ํ™•์ธํ•ด ๋ณด์„ธ์š”.

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