@@ -28,7 +28,7 @@ class DecimalPrecision(models.Model):
|
||||
@api.model
|
||||
@tools.ormcache('application')
|
||||
def precision_get(self, application):
|
||||
self.flush(['name', 'digits'])
|
||||
self.flush_model(['name', 'digits'])
|
||||
self.env.cr.execute('select digits from decimal_precision where name=%s', (application,))
|
||||
res = self.env.cr.fetchone()
|
||||
return res[0] if res else 2
|
||||
|
||||
@@ -107,7 +107,7 @@ class IrActions(models.Model):
|
||||
if not debug:
|
||||
user_groups -= self.env.ref('base.group_no_one')
|
||||
|
||||
self.flush()
|
||||
self.env.flush_all()
|
||||
cr.execute("""
|
||||
SELECT a.id, a.type, a.binding_type
|
||||
FROM ir_actions a
|
||||
|
||||
@@ -434,7 +434,7 @@ class IrAttachment(models.Model):
|
||||
model_ids = defaultdict(set) # {model_name: set(ids)}
|
||||
if self:
|
||||
# DLE P173: `test_01_portal_attachment`
|
||||
self.env['ir.attachment'].flush(['res_model', 'res_id', 'create_uid', 'public', 'res_field'])
|
||||
self.env['ir.attachment'].flush_model(['res_model', 'res_id', 'create_uid', 'public', 'res_field'])
|
||||
self._cr.execute('SELECT res_model, res_id, create_uid, public, res_field FROM ir_attachment WHERE id IN %s', [tuple(self.ids)])
|
||||
for res_model, res_id, create_uid, public, res_field in self._cr.fetchall():
|
||||
if public and mode == 'read':
|
||||
|
||||
@@ -71,7 +71,7 @@ class IrConfigParameter(models.Model):
|
||||
def _get_param(self, key):
|
||||
# we bypass the ORM because get_param() is used in some field's depends,
|
||||
# and must therefore work even when the ORM is not ready to work
|
||||
self.flush(['key', 'value'])
|
||||
self.flush_model(['key', 'value'])
|
||||
self.env.cr.execute("SELECT value FROM ir_config_parameter WHERE key = %s", [key])
|
||||
result = self.env.cr.fetchone()
|
||||
return result and result[0]
|
||||
|
||||
@@ -472,8 +472,8 @@ class ir_cron(models.Model):
|
||||
|
||||
def _neutralize(self):
|
||||
super()._neutralize()
|
||||
self.flush()
|
||||
self.invalidate_cache()
|
||||
self.env.flush_all()
|
||||
self.env.invalidate_all()
|
||||
self.env.cr.execute("""
|
||||
UPDATE ir_cron
|
||||
SET active = false
|
||||
|
||||
@@ -715,6 +715,6 @@ class IrMailServer(models.Model):
|
||||
|
||||
def _neutralize(self):
|
||||
super()._neutralize()
|
||||
self.flush()
|
||||
self.invalidate_cache()
|
||||
self.env.flush_all()
|
||||
self.env.invalidate_all()
|
||||
self.env.cr.execute("UPDATE ir_mail_server SET active = false")
|
||||
|
||||
@@ -290,7 +290,7 @@ class IrModel(models.Model):
|
||||
# reload is done independently in odoo.modules.loading.
|
||||
if not self._context.get(MODULE_UNINSTALL_FLAG):
|
||||
# setup models; this automatically removes model from registry
|
||||
self.flush()
|
||||
self.env.flush_all()
|
||||
self.pool.setup_models(self._cr)
|
||||
|
||||
return res
|
||||
@@ -311,7 +311,7 @@ class IrModel(models.Model):
|
||||
res = super(IrModel, self).write(vals)
|
||||
# ordering has been changed, reload registry to reflect update + signaling
|
||||
if 'order' in vals:
|
||||
self.flush() # setup_models need to fetch the updated values from the db
|
||||
self.env.flush_all() # setup_models need to fetch the updated values from the db
|
||||
self.pool.setup_models(self._cr)
|
||||
return res
|
||||
|
||||
@@ -323,7 +323,7 @@ class IrModel(models.Model):
|
||||
]
|
||||
if manual_models:
|
||||
# setup models; this automatically adds model in registry
|
||||
self.flush()
|
||||
self.env.flush_all()
|
||||
self.pool.setup_models(self._cr)
|
||||
# update database schema
|
||||
self.pool.init_models(self._cr, manual_models, dict(self._context, update_custom_fields=True))
|
||||
@@ -852,7 +852,7 @@ class IrModelFields(models.Model):
|
||||
# inconsistent in this case; therefore we reload the registry.
|
||||
if not self._context.get(MODULE_UNINSTALL_FLAG):
|
||||
# setup models; this re-initializes models in registry
|
||||
self.flush()
|
||||
self.env.flush_all()
|
||||
self.pool.setup_models(self._cr)
|
||||
# update database schema of model and its descendant models
|
||||
models = self.pool.descendants(model_names, '_inherits')
|
||||
@@ -890,7 +890,7 @@ class IrModelFields(models.Model):
|
||||
|
||||
if any(model in self.pool for model in models):
|
||||
# setup models; this re-initializes model in registry
|
||||
self.flush()
|
||||
self.env.flush_all()
|
||||
self.pool.setup_models(self._cr)
|
||||
# update database schema of models and their descendants
|
||||
models = self.pool.descendants(models, '_inherits')
|
||||
@@ -945,7 +945,7 @@ class IrModelFields(models.Model):
|
||||
|
||||
res = super(IrModelFields, self).write(vals)
|
||||
|
||||
self.flush()
|
||||
self.env.flush_all()
|
||||
|
||||
if column_rename:
|
||||
# rename column in database, and its corresponding index if present
|
||||
@@ -966,7 +966,7 @@ class IrModelFields(models.Model):
|
||||
|
||||
if column_rename or patched_models:
|
||||
# setup models, this will reload all manual fields in registry
|
||||
self.flush()
|
||||
self.env.flush_all()
|
||||
self.pool.setup_models(self._cr)
|
||||
|
||||
if patched_models:
|
||||
@@ -1181,7 +1181,7 @@ class IrModelSelection(models.Model):
|
||||
|
||||
def _get_selection(self, field_id):
|
||||
""" Return the given field's selection as a list of pairs (value, string). """
|
||||
self.flush(['value', 'name', 'field_id', 'sequence'])
|
||||
self.flush_model(['value', 'name', 'field_id', 'sequence'])
|
||||
return self._get_selection_data(field_id)
|
||||
|
||||
def _get_selection_data(self, field_id):
|
||||
@@ -1326,7 +1326,7 @@ class IrModelSelection(models.Model):
|
||||
for model, name in field_names
|
||||
):
|
||||
# setup models; this re-initializes model in registry
|
||||
self.flush()
|
||||
self.env.flush_all()
|
||||
self.pool.setup_models(self._cr)
|
||||
|
||||
return recs
|
||||
@@ -1355,7 +1355,7 @@ class IrModelSelection(models.Model):
|
||||
result = super().write(vals)
|
||||
|
||||
# setup models; this re-initializes model in registry
|
||||
self.flush()
|
||||
self.env.flush_all()
|
||||
self.pool.setup_models(self._cr)
|
||||
|
||||
return result
|
||||
@@ -1379,7 +1379,7 @@ class IrModelSelection(models.Model):
|
||||
# reload is done independently in odoo.modules.loading.
|
||||
if not self._context.get(MODULE_UNINSTALL_FLAG):
|
||||
# setup models; this re-initializes model in registry
|
||||
self.flush()
|
||||
self.env.flush_all()
|
||||
self.pool.setup_models(self._cr)
|
||||
|
||||
return result
|
||||
@@ -1407,7 +1407,7 @@ class IrModelSelection(models.Model):
|
||||
# we can do except fix on a case-by-case basis
|
||||
value = field.convert_to_column(value, records)
|
||||
self.env.cr.execute(query, [value, records._ids])
|
||||
records.invalidate_cache([fname])
|
||||
records.invalidate_recordset([fname])
|
||||
|
||||
for selection in self:
|
||||
Model = self.env[selection.field_id.model]
|
||||
@@ -1449,6 +1449,7 @@ class IrModelSelection(models.Model):
|
||||
""" Return the records having 'self' as a value. """
|
||||
self.ensure_one()
|
||||
Model = self.env[self.field_id.model]
|
||||
Model.flush_model([self.field_id.name])
|
||||
query = 'SELECT id FROM "{table}" WHERE "{field}"=%s'.format(
|
||||
table=Model._table, field=self.field_id.name,
|
||||
)
|
||||
@@ -1667,7 +1668,7 @@ class IrModelRelation(models.Model):
|
||||
(SELECT id FROM ir_module_module WHERE name=%s),
|
||||
(SELECT id FROM ir_model WHERE model=%s)) """
|
||||
cr.execute(query, (table, self.env.uid, self.env.uid, module, model._name))
|
||||
self.invalidate_cache()
|
||||
self.env.invalidate_all()
|
||||
|
||||
|
||||
class IrModelAccess(models.Model):
|
||||
@@ -1756,7 +1757,7 @@ class IrModelAccess(models.Model):
|
||||
if model not in self.env:
|
||||
_logger.error('Missing model %s', model)
|
||||
|
||||
self.flush(self._fields)
|
||||
self.flush_model()
|
||||
|
||||
# We check if a specific or generic rule exists
|
||||
self._cr.execute("""SELECT BOOL_OR(perm_{mode})
|
||||
@@ -1830,7 +1831,7 @@ class IrModelAccess(models.Model):
|
||||
|
||||
@api.model
|
||||
def call_cache_clearing_methods(self):
|
||||
self.invalidate_cache()
|
||||
self.env.invalidate_all()
|
||||
self.check.clear_cache(self) # clear the cache of check function
|
||||
for model, method in self.__cache_clearing_methods:
|
||||
if model in self.env:
|
||||
|
||||
@@ -81,6 +81,8 @@ class ModuleCategory(models.Model):
|
||||
|
||||
@api.depends('module_ids')
|
||||
def _compute_module_nr(self):
|
||||
self.env['ir.module.module'].flush_model(['category_id'])
|
||||
self.flush_model(['parent_id'])
|
||||
cr = self._cr
|
||||
cr.execute('SELECT category_id, COUNT(*) \
|
||||
FROM ir_module_module \
|
||||
@@ -520,6 +522,8 @@ class Module(models.Model):
|
||||
"""
|
||||
if not self:
|
||||
return self
|
||||
self.flush_model(['name', 'state'])
|
||||
self.env['ir.module.module.dependency'].flush_model(['module_id', 'name'])
|
||||
known_deps = known_deps or self.browse()
|
||||
query = """ SELECT DISTINCT m.id
|
||||
FROM ir_module_module_dependency d
|
||||
@@ -544,6 +548,8 @@ class Module(models.Model):
|
||||
"""
|
||||
if not self:
|
||||
return self
|
||||
self.flush_model(['name', 'state'])
|
||||
self.env['ir.module.module.dependency'].flush_model(['module_id', 'name'])
|
||||
known_deps = known_deps or self.browse()
|
||||
query = """ SELECT DISTINCT m.id
|
||||
FROM ir_module_module_dependency d
|
||||
@@ -894,6 +900,7 @@ class Module(models.Model):
|
||||
return tools.config.get('apps_server', 'https://apps.odoo.com/apps')
|
||||
|
||||
def _update_dependencies(self, depends=None, auto_install_requirements=()):
|
||||
self.env['ir.module.module.dependency'].flush_model()
|
||||
existing = set(dep.name for dep in self.dependencies_id)
|
||||
needed = set(depends or [])
|
||||
for dep in (needed - existing):
|
||||
@@ -902,16 +909,19 @@ class Module(models.Model):
|
||||
self._cr.execute('DELETE FROM ir_module_module_dependency WHERE module_id = %s and name = %s', (self.id, dep))
|
||||
self._cr.execute('UPDATE ir_module_module_dependency SET auto_install_required = (name = any(%s)) WHERE module_id = %s',
|
||||
(list(auto_install_requirements or ()), self.id))
|
||||
self.invalidate_cache(['dependencies_id'], self.ids)
|
||||
self.env['ir.module.module.dependency'].invalidate_model()
|
||||
self.invalidate_recordset(['dependencies_id'])
|
||||
|
||||
def _update_exclusions(self, excludes=None):
|
||||
self.env['ir.module.module.exclusion'].flush_model()
|
||||
existing = set(excl.name for excl in self.exclusion_ids)
|
||||
needed = set(excludes or [])
|
||||
for name in (needed - existing):
|
||||
self._cr.execute('INSERT INTO ir_module_module_exclusion (module_id, name) VALUES (%s, %s)', (self.id, name))
|
||||
for name in (existing - needed):
|
||||
self._cr.execute('DELETE FROM ir_module_module_exclusion WHERE module_id=%s AND name=%s', (self.id, name))
|
||||
self.invalidate_cache(['exclusion_ids'], self.ids)
|
||||
self.env['ir.module.module.exclusion'].invalidate_model()
|
||||
self.invalidate_recordset(['exclusion_ids'])
|
||||
|
||||
def _update_category(self, category='Uncategorized'):
|
||||
current_category = self.category_id
|
||||
@@ -954,6 +964,7 @@ class Module(models.Model):
|
||||
|
||||
@tools.ormcache('name')
|
||||
def _get_id(self, name):
|
||||
self.flush_model(['name'])
|
||||
self.env.cr.execute("SELECT id FROM ir_module_module WHERE name=%s", (name,))
|
||||
return self.env.cr.fetchone()
|
||||
|
||||
|
||||
@@ -123,7 +123,7 @@ class Property(models.Model):
|
||||
# Easy solution, need to flush write when changing a property.
|
||||
# Maybe it would be better to be able to compute all impacted cache value and update those instead
|
||||
# Then clear_caches must be removed as well.
|
||||
self.flush()
|
||||
self.env.flush_all()
|
||||
self.clear_caches()
|
||||
return r
|
||||
|
||||
@@ -134,7 +134,7 @@ class Property(models.Model):
|
||||
r = super(Property, self).create(vals_list)
|
||||
if created_default:
|
||||
# DLE P44: test `test_27_company_dependent`
|
||||
self.flush()
|
||||
self.env.flush_all()
|
||||
self.clear_caches()
|
||||
return r
|
||||
|
||||
|
||||
@@ -173,7 +173,7 @@ class IrRule(models.Model):
|
||||
def create(self, vals_list):
|
||||
res = super(IrRule, self).create(vals_list)
|
||||
# DLE P33: tests
|
||||
self.flush()
|
||||
self.env.flush_all()
|
||||
self.clear_caches()
|
||||
return res
|
||||
|
||||
@@ -183,7 +183,7 @@ class IrRule(models.Model):
|
||||
# - odoo/addons/test_access_rights/tests/test_feedback.py
|
||||
# - odoo/addons/test_access_rights/tests/test_ir_rules.py
|
||||
# - odoo/addons/base/tests/test_orm.py (/home/dle/src/odoo/master-nochange-fp/odoo/addons/base/tests/test_orm.py)
|
||||
self.flush()
|
||||
self.env.flush_all()
|
||||
self.clear_caches()
|
||||
return res
|
||||
|
||||
|
||||
@@ -52,10 +52,11 @@ def _select_nextval(cr, seq_name):
|
||||
|
||||
|
||||
def _update_nogap(self, number_increment):
|
||||
self.flush_recordset(['number_next'])
|
||||
number_next = self.number_next
|
||||
self._cr.execute("SELECT number_next FROM %s WHERE id=%%s FOR UPDATE NOWAIT" % self._table, [self.id])
|
||||
self._cr.execute("UPDATE %s SET number_next=number_next+%%s WHERE id=%%s " % self._table, (number_increment, self.id))
|
||||
self.invalidate_cache(['number_next'], [self.id])
|
||||
self.invalidate_recordset(['number_next'])
|
||||
return number_next
|
||||
|
||||
def _predict_nextval(self, seq_id):
|
||||
@@ -192,7 +193,7 @@ class IrSequence(models.Model):
|
||||
_create_sequence(self._cr, "ir_sequence_%03d_%03d" % (seq.id, sub_seq.id), i, n)
|
||||
res = super(IrSequence, self).write(values)
|
||||
# DLE P179
|
||||
self.flush(values.keys())
|
||||
self.flush_model(values.keys())
|
||||
return res
|
||||
|
||||
def _next_do(self):
|
||||
@@ -385,5 +386,5 @@ class IrSequenceDateRange(models.Model):
|
||||
# - But selecting the number next happens a lot,
|
||||
# Therefore, if I chose to put the flush just above the select, it would check the flush most of the time for no reason.
|
||||
res = super(IrSequenceDateRange, self).write(values)
|
||||
self.flush(values.keys())
|
||||
self.flush_model(values.keys())
|
||||
return res
|
||||
|
||||
@@ -281,6 +281,7 @@ class IrTranslation(models.Model):
|
||||
:param ids: the ids of the given records
|
||||
:param src: the source of the translation
|
||||
"""
|
||||
self.flush_model()
|
||||
self._cr.execute("""UPDATE ir_translation
|
||||
SET src=%s
|
||||
WHERE type=%s AND name=%s AND res_id IN %s
|
||||
@@ -288,10 +289,11 @@ class IrTranslation(models.Model):
|
||||
(src, 'model', name, tuple(ids)))
|
||||
existing_ids = [row[0] for row in self._cr.fetchall()]
|
||||
# invalidate src for updated translations
|
||||
self.invalidate_cache(fnames=['src'], ids=existing_ids)
|
||||
self.browse(existing_ids).invalidate_recordset(['src'])
|
||||
|
||||
@api.model
|
||||
def _get_source_query(self, name, types, lang, source, res_id):
|
||||
self.flush_model()
|
||||
if source:
|
||||
# Note: the extra test on md5(src) is a hint for postgres to use the
|
||||
# index ir_translation_src_md5
|
||||
@@ -354,6 +356,7 @@ class IrTranslation(models.Model):
|
||||
@api.model
|
||||
def _get_terms_query(self, field, records):
|
||||
""" Utility function that makes the query for field terms. """
|
||||
self.flush_model()
|
||||
query = """ SELECT * FROM ir_translation
|
||||
WHERE lang=%s AND type=%s AND name=%s AND res_id IN %s """
|
||||
name = "%s,%s" % (field.model_name, field.name)
|
||||
@@ -452,8 +455,8 @@ class IrTranslation(models.Model):
|
||||
# delete in SQL to avoid invalidating the whole cache
|
||||
discarded._modified()
|
||||
discarded.modified(self._fields)
|
||||
self.flush(self._fields, discarded)
|
||||
self.invalidate_cache(ids=discarded._ids)
|
||||
discarded.flush_recordset()
|
||||
discarded.invalidate_recordset()
|
||||
self.env.cr.execute("DELETE FROM ir_translation WHERE id IN %s", [discarded._ids])
|
||||
|
||||
@api.model
|
||||
@@ -557,7 +560,7 @@ class IrTranslation(models.Model):
|
||||
records.check('create')
|
||||
records._modified()
|
||||
# DLE P62: `test_translate.py`, `test_sync`
|
||||
self.flush()
|
||||
self.env.flush_all()
|
||||
return records
|
||||
|
||||
def write(self, vals):
|
||||
@@ -574,7 +577,7 @@ class IrTranslation(models.Model):
|
||||
# the flush to database is not done.
|
||||
# this causes issues when changing the src/value of a translation, as when we read, we ask the flush,
|
||||
# but its not really the field which is in the towrite values, but its translation
|
||||
self.flush()
|
||||
self.env.flush_all()
|
||||
return result
|
||||
|
||||
def unlink(self):
|
||||
@@ -589,12 +592,13 @@ class IrTranslation(models.Model):
|
||||
# e.g. email.with_context(lang='fr_FR').label = "bonjour"
|
||||
# and then search on translations for this translation, must flush as the translation has not yet been written in database
|
||||
if any(self.env[model]._fields[field].translate for model, ids in self.env.all.towrite.items() for record_id, fields in ids.items() for field in fields):
|
||||
self.flush()
|
||||
self.env.flush_all()
|
||||
return super(IrTranslation, self)._search(args, offset=offset, limit=limit, order=order, count=count, access_rights_uid=access_rights_uid)
|
||||
|
||||
@api.model
|
||||
def insert_missing(self, field, records):
|
||||
""" Insert missing translations for `field` on `records`. """
|
||||
self.flush_model()
|
||||
records = records.with_context(lang=None)
|
||||
external_ids = records.get_external_id() # if no xml_id, empty string
|
||||
if callable(field.translate):
|
||||
@@ -658,6 +662,7 @@ class IrTranslation(models.Model):
|
||||
Mandatory values: name, lang, res_id, src, type
|
||||
The other keys are ignored during update if not present
|
||||
"""
|
||||
self.flush_model()
|
||||
rows_by_type = defaultdict(list)
|
||||
for vals in vals_list:
|
||||
rows_by_type[vals['type']].append((
|
||||
@@ -701,6 +706,7 @@ class IrTranslation(models.Model):
|
||||
``vals_list`` is trusted to be the right values
|
||||
No new translation will be created
|
||||
"""
|
||||
self.flush_model()
|
||||
grouped_rows = {}
|
||||
for vals in vals_list:
|
||||
key = (vals['lang'], vals['type'], vals['name'])
|
||||
|
||||
@@ -320,7 +320,7 @@ actual arch.
|
||||
# the field 'arch' depends on the context and has been implicitly
|
||||
# modified in all languages; the invalidation below ensures that the
|
||||
# field does not keep an old value in another environment
|
||||
self.invalidate_cache(['arch'], self._ids)
|
||||
self.invalidate_recordset(['arch'])
|
||||
|
||||
@api.depends('arch')
|
||||
@api.depends_context('read_arch_from_file')
|
||||
|
||||
@@ -227,7 +227,7 @@ class Company(models.Model):
|
||||
for vals in no_partner_vals_list
|
||||
])
|
||||
# compute stored fields, for example address dependent fields
|
||||
partners.flush()
|
||||
partners.flush_model()
|
||||
for vals, partner in zip(no_partner_vals_list, partners):
|
||||
vals['partner_id'] = partner.id
|
||||
|
||||
@@ -259,7 +259,7 @@ class Company(models.Model):
|
||||
company_address_fields = self._get_company_address_field_names()
|
||||
company_address_fields_upd = set(company_address_fields) & set(values.keys())
|
||||
if company_address_fields_upd:
|
||||
self.invalidate_cache(fnames=company_address_fields)
|
||||
self.invalidate_model(company_address_fields)
|
||||
return res
|
||||
|
||||
@api.constrains('parent_id')
|
||||
|
||||
@@ -629,7 +629,7 @@ class ResConfigSettings(models.TransientModel, ResConfigModuleInstallationMixin)
|
||||
lambda m: not self[f'module_{m.name}'] and m.state in ('installed', 'to upgrade'))
|
||||
|
||||
if to_install or to_uninstall:
|
||||
self.flush()
|
||||
self.env.flush_all()
|
||||
|
||||
if to_uninstall:
|
||||
to_uninstall.button_immediate_uninstall()
|
||||
|
||||
@@ -98,7 +98,7 @@ class Currency(models.Model):
|
||||
def _get_rates(self, company, date):
|
||||
if not self.ids:
|
||||
return {}
|
||||
self.env['res.currency.rate'].flush(['rate', 'currency_id', 'company_id', 'name'])
|
||||
self.env['res.currency.rate'].flush_model(['rate', 'currency_id', 'company_id', 'name'])
|
||||
query = """SELECT c.id,
|
||||
COALESCE((SELECT r.rate FROM res_currency_rate r
|
||||
WHERE r.currency_id = c.id AND r.name <= %s
|
||||
|
||||
@@ -289,7 +289,7 @@ class Lang(models.Model):
|
||||
self.env['ir.default'].discard_values('res.partner', 'lang', lang_codes)
|
||||
|
||||
res = super(Lang, self).write(vals)
|
||||
self.flush()
|
||||
self.env.flush_all()
|
||||
self.clear_caches()
|
||||
return res
|
||||
|
||||
|
||||
@@ -564,7 +564,7 @@ class Partner(models.Model):
|
||||
# RCO: when creating a user for partner, the user is automatically added in partner.user_ids.
|
||||
# This is wrong if the user is not active, as partner.user_ids only returns active users.
|
||||
# Hence this temporary hack until the ORM updates inverse fields correctly.
|
||||
self.invalidate_cache(['user_ids'], self._ids)
|
||||
self.invalidate_recordset(['user_ids'])
|
||||
users = self.env['res.users'].sudo().search([('partner_id', 'in', self.ids)])
|
||||
if users:
|
||||
if self.env['res.users'].sudo(False).check_access_rights('write', raise_exception=False):
|
||||
|
||||
@@ -353,7 +353,7 @@ class Users(models.Model):
|
||||
'UPDATE res_users SET password=%s WHERE id=%s',
|
||||
(pw, uid)
|
||||
)
|
||||
self.invalidate_cache(['password'], [uid])
|
||||
self.browse(uid).invalidate_recordset(['password'])
|
||||
|
||||
def _check_credentials(self, password, env):
|
||||
""" Validates the current user's password.
|
||||
|
||||
@@ -114,7 +114,7 @@ class TestACL(TransactionCaseWithUserDemo):
|
||||
"""Test access to records having restricted fields"""
|
||||
# Invalidate cache to avoid restricted value to be available
|
||||
# in the cache
|
||||
self.user_demo.invalidate_cache()
|
||||
self.env.invalidate_all()
|
||||
partner = self.env['res.partner'].with_user(self.user_demo)
|
||||
self._set_field_groups(partner, 'email', GROUP_SYSTEM)
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ class TestTestCursor(common.TransactionCase):
|
||||
record.ref = value
|
||||
|
||||
def flush(self, record):
|
||||
record.flush(['ref'])
|
||||
record.flush_model(['ref'])
|
||||
|
||||
def check(self, record, value):
|
||||
self.assertEqual(record.read(['ref'])[0]['ref'], value)
|
||||
|
||||
@@ -499,7 +499,7 @@ class TestCustomFields(common.TransactionCase):
|
||||
partners = self.env['res.partner'].create([
|
||||
{'name': country.code, 'country_id': country.id} for country in countries
|
||||
])
|
||||
partners.flush()
|
||||
self.env.flush_all()
|
||||
|
||||
# create a non-computed field, and assert how many queries it takes
|
||||
model_id = self.env['ir.model']._get_id('res.partner')
|
||||
|
||||
@@ -246,8 +246,8 @@ class TestPermissions(TransactionCase):
|
||||
'domain_force': "[('id', '!=', %s)]" % record.id,
|
||||
'perm_read': False
|
||||
})
|
||||
a.flush()
|
||||
a.invalidate_cache(ids=a.ids)
|
||||
self.env.flush_all()
|
||||
a.invalidate_recordset()
|
||||
|
||||
def test_no_read_permission(self):
|
||||
"""If the record can't be read, the attachment can't be read either
|
||||
@@ -256,7 +256,7 @@ class TestPermissions(TransactionCase):
|
||||
self.attachment.datas
|
||||
# prevent read access on record
|
||||
self.rule.perm_read = True
|
||||
self.attachment.invalidate_cache(ids=self.attachment.ids)
|
||||
self.attachment.invalidate_recordset()
|
||||
with self.assertRaises(AccessError):
|
||||
self.attachment.datas
|
||||
|
||||
|
||||
@@ -94,8 +94,8 @@ class test_ir_http_mimetype(common.TransactionCase):
|
||||
# as the attachment has just been created above as sudo, the data is in cache and if we don't remove it the below
|
||||
# `test_access` wont have to fetch it and therefore wont raise the accesserror as its already in the cache
|
||||
# `__last_update` must be removed from the cache when `test_access` is called, which happens and recompute the todos
|
||||
attachment.flush()
|
||||
attachment.invalidate_cache()
|
||||
attachment.env.flush_all()
|
||||
attachment.env.invalidate_all()
|
||||
status, _, _ = self.env['ir.http'].with_user(public_user).binary_content(
|
||||
**dict(defaults, **kwargs)
|
||||
)
|
||||
|
||||
@@ -553,7 +553,7 @@ class TestProfiling(TransactionCase):
|
||||
queries_start = self.env.cr.sql_log_count
|
||||
for i in range(10):
|
||||
self.env['res.partner'].create({'name': 'snail%s' % i})
|
||||
self.env['res.partner'].flush()
|
||||
self.env.flush_all()
|
||||
total_queries = self.env.cr.sql_log_count - queries_start
|
||||
|
||||
rq = next(r for r in p.collectors if r.name == "sql").entries
|
||||
|
||||
@@ -252,7 +252,7 @@ class TestLanguageInstall(TransactionCase):
|
||||
fr = self.env['res.lang'].with_context(active_test=False).search([('code', '=', 'fr_FR')])
|
||||
self.assertTrue(fr)
|
||||
wizard = self.env['base.language.install'].create({'lang_ids': fr.ids})
|
||||
wizard.flush()
|
||||
self.env.flush_all()
|
||||
|
||||
# running the wizard calls _load_module_terms() to load PO files
|
||||
loaded = []
|
||||
@@ -390,7 +390,7 @@ class TestTranslation(TransactionCase):
|
||||
self.assertEqual(cheese.with_context(lang=None).name, 'Cheese')
|
||||
self.assertEqual(cheese.with_context(lang='fr_FR').name, 'Fromage')
|
||||
self.assertEqual(cheese.with_context(lang='en_US').name, 'The Cheese')
|
||||
cheese.flush()
|
||||
self.env.flush_all()
|
||||
|
||||
# set a new master value
|
||||
cheese.with_context(lang='en_US').write({'name': 'Delicious Cheese'})
|
||||
@@ -622,8 +622,8 @@ class TestTranslationWrite(TransactionCase):
|
||||
'value': 'Parfum Exquis',
|
||||
'state': 'translated',
|
||||
})
|
||||
translation.flush()
|
||||
translation.invalidate_cache()
|
||||
self.env.flush_all()
|
||||
self.env.invalidate_all()
|
||||
self.cr.execute("DELETE FROM res_partner_category WHERE id=%s", [self.category.id])
|
||||
|
||||
# deleting the translation should be possible, provided the user has
|
||||
@@ -670,8 +670,8 @@ class TestTranslationWrite(TransactionCase):
|
||||
'value': 'Fromage',
|
||||
'state': 'translated',
|
||||
})
|
||||
translation.flush()
|
||||
translation.invalidate_cache()
|
||||
self.env.flush_all()
|
||||
self.env.invalidate_all()
|
||||
|
||||
# deleting the translation should be possible, provided the user has
|
||||
# access rights on the translation's model
|
||||
@@ -743,7 +743,7 @@ class TestXMLTranslation(TransactionCase):
|
||||
# `arch_db` is in `_write` instead of `create` because `arch_db` is the inverse of `arch`.
|
||||
# We need to flush `arch_db` before creating the translations otherwise the translation for which there is no value will be deleted,
|
||||
# while the `test_sync_update` specifically needs empty translations
|
||||
view.flush()
|
||||
self.env.flush_all()
|
||||
for lang, trans_terms in kwargs.items():
|
||||
for src, val in zip(terms, trans_terms):
|
||||
self.env['ir.translation'].create({
|
||||
|
||||
@@ -280,7 +280,7 @@ class TestViewInheritance(ViewCase):
|
||||
# If the query count increases, you probably made the view combination
|
||||
# fetch an extra field on views. You better fetch that extra field with
|
||||
# the query of _get_inheriting_views() and manually feed the cache.
|
||||
self.View.invalidate_cache()
|
||||
self.env.invalidate_all()
|
||||
with self.assertQueryCount(3):
|
||||
# 1: browse([self.view_ids['A']])
|
||||
# 2: _get_inheriting_views: id, inherit_id, mode, groups
|
||||
@@ -2510,7 +2510,7 @@ class TestViewTranslations(common.TransactionCase):
|
||||
# `arch_db` is in `_write` instead of `create` because `arch_db` is the inverse of `arch`.
|
||||
# We need to flush `arch_db` before creating the translations otherwise the translation for which there is no value will be deleted,
|
||||
# while the `test_sync_update` specifically needs empty translations
|
||||
view.flush()
|
||||
self.env.flush_all()
|
||||
self.env['ir.translation'].create([
|
||||
{
|
||||
'type': 'model_terms',
|
||||
@@ -2712,7 +2712,7 @@ class ViewModeField(ViewCase):
|
||||
})
|
||||
with self.assertRaises(IntegrityError):
|
||||
view_pure_primary.write({'mode': 'extension'})
|
||||
view_pure_primary.flush()
|
||||
view_pure_primary.env.flush_all()
|
||||
|
||||
def testInheritPrimaryToExtension(self):
|
||||
"""
|
||||
@@ -3239,7 +3239,7 @@ class TestRenderAllViews(common.TransactionCase):
|
||||
with self.subTest(model=model):
|
||||
times = []
|
||||
for _ in range(5):
|
||||
model.invalidate_cache()
|
||||
env.invalidate_all()
|
||||
before = time.perf_counter()
|
||||
model.get_view()
|
||||
times.append(time.perf_counter() - before)
|
||||
|
||||
@@ -112,7 +112,7 @@ class MergePartnerAutomatic(models.TransientModel):
|
||||
Partner = self.env['res.partner']
|
||||
relations = self._get_fk_on('res_partner')
|
||||
|
||||
self.flush()
|
||||
self.env.flush_all()
|
||||
|
||||
for table, column in relations:
|
||||
if 'base_partner_merge_' in table: # ignore two tables
|
||||
@@ -175,7 +175,7 @@ class MergePartnerAutomatic(models.TransientModel):
|
||||
query = 'DELETE FROM "%(table)s" WHERE "%(column)s" IN %%s' % query_dic
|
||||
self._cr.execute(query, (tuple(src_partners.ids),))
|
||||
|
||||
self.invalidate_cache()
|
||||
self.env.invalidate_all()
|
||||
|
||||
@api.model
|
||||
def _update_reference_fields(self, src_partners, dst_partner):
|
||||
@@ -193,7 +193,7 @@ class MergePartnerAutomatic(models.TransientModel):
|
||||
try:
|
||||
with mute_logger('odoo.sql_db'), self._cr.savepoint():
|
||||
records.sudo().write({field_id: dst_partner.id})
|
||||
records.flush()
|
||||
records.env.flush_all()
|
||||
except psycopg2.Error:
|
||||
# updating fails, most likely due to a violated unique constraint
|
||||
# keeping record with nonexistent partner_id is useless, better delete it
|
||||
@@ -228,7 +228,7 @@ class MergePartnerAutomatic(models.TransientModel):
|
||||
}
|
||||
records_ref.sudo().write(values)
|
||||
|
||||
self.flush()
|
||||
self.env.flush_all()
|
||||
|
||||
def _get_summable_fields(self):
|
||||
""" Returns the list of fields that should be summed when merging partners
|
||||
@@ -458,7 +458,7 @@ class MergePartnerAutomatic(models.TransientModel):
|
||||
next wizard line. Each line is a subset of partner that can be merged together.
|
||||
If no line left, the end screen will be displayed (but an action is still returned).
|
||||
"""
|
||||
self.invalidate_cache() # FIXME: is this still necessary?
|
||||
self.env.invalidate_all() # FIXME: is this still necessary?
|
||||
values = {}
|
||||
if self.line_ids:
|
||||
# in this case, we try to find the next record.
|
||||
@@ -542,7 +542,7 @@ class MergePartnerAutomatic(models.TransientModel):
|
||||
"""
|
||||
self.ensure_one()
|
||||
self.action_start_manual_process() # here we don't redirect to the next screen, since it is automatic process
|
||||
self.invalidate_cache() # FIXME: is this still necessary?
|
||||
self.env.invalidate_all() # FIXME: is this still necessary?
|
||||
|
||||
for line in self.line_ids:
|
||||
partner_ids = literal_eval(line.aggr_ids)
|
||||
|
||||
Reference in New Issue
Block a user