Browse Source

publish muk_security - 12.0

pull/9/head
MuK IT GmbH 6 years ago
parent
commit
051dfa4249
  1. 2
      muk_security/__manifest__.py
  2. 15
      muk_security/models/mixins_locking.py

2
muk_security/__manifest__.py

@ -20,7 +20,7 @@
{
"name": "MuK Security",
"summary": """Security Features""",
"version": "12.0.1.2.7",
"version": "12.0.1.2.8",
"category": "Extra Tools",
"license": "AGPL-3",
"website": "http://www.mukit.at",

15
muk_security/models/mixins_locking.py

@ -64,14 +64,15 @@ class LockingModel(models.AbstractModel):
self.write({'locked_by': None})
@api.model
def _check_lock_user(self, uid):
return uid in (self.env.uid, SUPERUSER_ID) or isinstance(self.env.uid, NoSecurityUid)
def _check_lock_editor(self, lock_uid):
return lock_uid in (self.env.uid, SUPERUSER_ID) or isinstance(self.env.uid, NoSecurityUid)
@api.multi
def check_lock(self, *largs, **kwargs):
def check_lock(self):
for record in self:
if record.locked_by.exists() and not self._check_lock_user(record.locked_by.id):
raise AccessError(_("The record (%s [%s]) is locked, by an other user.") % (record._description, record.id))
if record.locked_by.exists() and not self._check_lock_editor(record.locked_by.id):
message = _("The record (%s [%s]) is locked, by an other user.")
raise AccessError(message % (record._description, record.id))
#----------------------------------------------------------
# Read, View
@ -90,9 +91,9 @@ class LockingModel(models.AbstractModel):
#----------------------------------------------------------
@api.multi
def write(self, vals):
def _write(self, vals):
self.check_lock()
return super(BaseModelLocking, self).write(vals)
return super(BaseModelLocking, self)._write(vals)
@api.multi

Loading…
Cancel
Save