1
# -*- encoding: utf-8 -*-
2
##############################################################################
4
# Author Nicolas Bessi. Copyright Camptocamp SA
5
##############################################################################
6
from osv import fields, osv
8
class IrModelAccess(osv.osv):
9
"We inherit ir model access to add specific write unlink and copy behavior"
10
_name = 'ir.model.access'
11
_inherit = "ir.model.access"
13
def _acces_can_be_modified(self, cr, uid, context=None):
14
context = context or {}
15
on = self.pool.get('ir.config_parameter').get_param(cr, uid, 'protect_security?', default=False, context=context)
16
if on in (1, "1", "YES", True):
17
if context.get('manual_security_override', False):
24
def write(self, cr, uid, ids, vals, context=None):
26
context = context or {}
27
if self._acces_can_be_modified(cr, uid, context=context):
28
res = super(IrModelAccess, self).write(cr, uid, ids, vals, context=context)
32
def unlink(self, cr, uid, ids, context=None):
34
context = context or {}
35
if self._acces_can_be_modified(cr, uid, context=context):
36
res = super(IrModelAccess, self).write(cr, uid, ids, context=context)
37
else: # I'm note sur about this one maybe we should do nothing
38
self.write(cr, uid, args[0],
42
'perm_create': False},
b'\\ No newline at end of file'