[FIX] base_import_module: avoid warning when browsing industry modules
An ormcache has been added to a method that takes lists as parameters but
lists are not hashable.
steps to reproduce:
- go to apps and click on on 'Industries'
before this commit:
- a warning is raised in the logs:
WARNING industry odoo.tools.cache: cache lookup error on ('ir.module.module', <function IrModule._get_modules_from_apps at 0x7f99e842fc70>, ['icon', 'icon_flag', 'to_buy', 'name', 'state', 'summary', 'website', 'application', 'module_type', 'shortdesc'], 'industries', False, ['&', '!', ['name', '=like', 'theme_%'], '&', ['application', '=', True], ['module_type', '=', 'industries']], 80, 0)
Traceback (most recent call last):
File "/home/nda/dev/odoo/17.0/odoo/odoo/tools/cache.py", line 99, in lookup
r = d[key]
File "<decorator-gen-5>", line 2, in __getitem__
File "/home/nda/dev/odoo/17.0/odoo/odoo/tools/func.py", line 87, in locked
return func(inst, *args, **kwargs)
File "/home/nda/dev/odoo/17.0/odoo/odoo/tools/lru.py", line 34, in __getitem__
a = self.d[obj]
TypeError: unhashable type: 'list'
after this commit:
- ormcache is properly used
opw-3660052
closes odoo/odoo#147730
Signed-off-by: Rémy Voet (ryv) <ryv@odoo.com>
This commit is contained in:
@@ -25,6 +25,8 @@ _logger = logging.getLogger(__name__)
|
||||
APPS_URL = "https://apps.odoo.com"
|
||||
MAX_FILE_SIZE = 100 * 1024 * 1024 # in megabytes
|
||||
|
||||
def to_tuple(t):
|
||||
return tuple(map(to_tuple, t)) if isinstance(t, (list, tuple)) else t
|
||||
|
||||
class IrModule(models.Model):
|
||||
_inherit = "ir.module.module"
|
||||
@@ -283,8 +285,9 @@ class IrModule(models.Model):
|
||||
@api.model
|
||||
def web_search_read(self, domain, specification, offset=0, limit=None, order=None, count_limit=None):
|
||||
if _domain_asks_for_industries(domain):
|
||||
fields_name = list(specification.keys())
|
||||
modules_list = self._get_modules_from_apps(fields_name, 'industries', False, domain, offset=offset, limit=limit)
|
||||
fields_name = tuple(specification.keys())
|
||||
domain_tuple = to_tuple(domain or [])
|
||||
modules_list = self._get_modules_from_apps(fields_name, 'industries', False, domain_tuple, offset=offset, limit=limit)
|
||||
return {
|
||||
'length': len(modules_list),
|
||||
'records': modules_list,
|
||||
@@ -303,7 +306,7 @@ class IrModule(models.Model):
|
||||
}
|
||||
|
||||
def web_read(self, specification):
|
||||
fields = list(specification.keys())
|
||||
fields = tuple(specification.keys())
|
||||
module_type = self.env.context.get('module_type', 'official')
|
||||
if module_type != 'official':
|
||||
modules_list = self._get_modules_from_apps(fields, module_type, self.env.context.get('module_name'))
|
||||
|
||||
Reference in New Issue
Block a user