[REM] core: remove _check_concurrency method
`_check_concurrency` was used to check if 2 people were modifying the same record at the same time. It was doing so by setting a special `__last_update` value inside the context that was later evaluted to prevent some concurrency issues. It was mostly unused, wasted a lot of cpu cycles and was not covering all cases (e.g. pending write). closes odoo/odoo#87756 Signed-off-by: Vincent Schippefilt (vsc) <vsc@odoo.com>
This commit is contained in:
@@ -296,8 +296,6 @@ class IrModel(models.Model):
|
||||
return res
|
||||
|
||||
def write(self, vals):
|
||||
if '__last_update' in self._context:
|
||||
self = self.with_context({k: v for k, v in self._context.items() if k != '__last_update'})
|
||||
if 'model' in vals and any(rec.model != vals['model'] for rec in self):
|
||||
raise UserError(_('Field "Model" cannot be modified on models.'))
|
||||
if 'state' in vals and any(rec.state != vals['state'] for rec in self):
|
||||
|
||||
@@ -3575,31 +3575,6 @@ class BaseModel(metaclass=MetaModel):
|
||||
raise ValueError("Expected singleton or no record: %s" % self)
|
||||
return self.env['ir.config_parameter'].sudo().get_param('web.base.url')
|
||||
|
||||
def _check_concurrency(self):
|
||||
if not (self._log_access and self._context.get(self.CONCURRENCY_CHECK_FIELD)):
|
||||
return
|
||||
check_clause = "(id = %s AND %s < COALESCE(write_date, create_date, (now() at time zone 'UTC'))::timestamp)"
|
||||
for sub_ids in self._cr.split_for_in_conditions(self.ids):
|
||||
nclauses = 0
|
||||
params = []
|
||||
for id in sub_ids:
|
||||
id_ref = "%s,%s" % (self._name, id)
|
||||
update_date = self._context[self.CONCURRENCY_CHECK_FIELD].pop(id_ref, None)
|
||||
if update_date:
|
||||
nclauses += 1
|
||||
params.extend([id, update_date])
|
||||
if not nclauses:
|
||||
continue
|
||||
query = "SELECT id FROM %s WHERE %s" % (self._table, " OR ".join([check_clause] * nclauses))
|
||||
self._cr.execute(query, tuple(params))
|
||||
res = self._cr.fetchone()
|
||||
if res:
|
||||
# mention the first one only to keep the error message readable
|
||||
raise ValidationError(_(
|
||||
"A document was modified since you last viewed it (%s:%d)",
|
||||
self._description, res[0],
|
||||
))
|
||||
|
||||
def _check_company(self, fnames=None):
|
||||
""" Check the companies of the values of the given field names.
|
||||
|
||||
@@ -3771,7 +3746,6 @@ class BaseModel(metaclass=MetaModel):
|
||||
|
||||
self.check_access_rights('unlink')
|
||||
self.check_access_rule('unlink')
|
||||
self._check_concurrency()
|
||||
|
||||
from odoo.addons.base.models.ir_model import MODULE_UNINSTALL_FLAG
|
||||
for func in self._ondelete_methods:
|
||||
@@ -4057,7 +4031,6 @@ class BaseModel(metaclass=MetaModel):
|
||||
if not self:
|
||||
return
|
||||
|
||||
self._check_concurrency()
|
||||
cr = self._cr
|
||||
|
||||
# determine records that require updating parent_path
|
||||
|
||||
Reference in New Issue
Block a user