[IMP] base: optimize code with search_fetch() and fetch()
Part-of: odoo/odoo#112126
This commit is contained in:
@@ -72,10 +72,12 @@ class IrFilters(models.Model):
|
||||
"""
|
||||
# available filters: private filters (user_id=uid) and public filters (uid=NULL),
|
||||
# and filters for the action (action_id=action_id) or global (action_id=NULL)
|
||||
action_domain = self._get_action_domain(action_id)
|
||||
filters = self.search(action_domain + [('model_id', '=', model), ('user_id', 'in', [self._uid, False])])
|
||||
user_context = self.env['res.users'].context_get()
|
||||
return filters.with_context(user_context).read(['name', 'is_default', 'domain', 'context', 'user_id', 'sort'])
|
||||
action_domain = self._get_action_domain(action_id)
|
||||
return self.with_context(user_context).search_read(
|
||||
action_domain + [('model_id', '=', model), ('user_id', 'in', [self._uid, False])],
|
||||
['name', 'is_default', 'domain', 'context', 'user_id', 'sort'],
|
||||
)
|
||||
|
||||
@api.model
|
||||
def _check_global_default(self, vals, matching_filters):
|
||||
|
||||
@@ -1055,7 +1055,7 @@ class Partner(models.Model):
|
||||
"""
|
||||
States = self.env['res.country.state']
|
||||
states_ids = {vals['state_id'] for vals in vals_list if vals.get('state_id')}
|
||||
state_to_country = States.search([('id', 'in', list(states_ids))]).read(['country_id'])
|
||||
state_to_country = States.search_read([('id', 'in', list(states_ids))], ['country_id'])
|
||||
for vals in vals_list:
|
||||
if vals.get('state_id'):
|
||||
country_id = next(c['country_id'][0] for c in state_to_country if c['id'] == vals.get('state_id'))
|
||||
|
||||
Reference in New Issue
Block a user