<commit_before># -*- encoding: utf-8 -*-
##############################################################################
#
#    Author <NAME>. Copyright Camptocamp SA
##############################################################################
from osv import fields, osv

class IrModelAccess(osv.osv):
    "We inherit ir model access to add specific write unlink and copy behavior"
    _name = 'ir.model.access'
    _inherit = "ir.model.access"
                    
    def _acces_can_be_modified(self, cr, uid, context=None):
        context = context or {}
        on = self.pool.get('ir.config_parameter').get_param(cr, uid, 'protect_security?', default=False, context=context)
        if on in (1, "1", "YES", True):
            if context.get('manual_security_override', False):
                return True
            return False
            
        else:
            return True
        
    def write(self, cr, uid, ids, vals, context=None):
        res =True
        context = context or {}
        if self._acces_can_be_modified(cr, uid, context=context):
            res = super(IrModelAccess, self).write(cr, uid, ids, vals, context=context)
        return res


    def unlink(self, cr, uid, ids, context=None):
        res = True
        context = context or {}
        if self._acces_can_be_modified(cr, uid, context=context):
            res = super(IrModelAccess, self).write(cr, uid, ids, context=context)
        else: # I'm note sur about this one maybe we should do nothing
            self.write(cr, uid, args[0], 
                       {'perm_read':False,
                        'perm_write': False, 
                        'perm_unlink': False,
                        'perm_create': False}, 
                       context={context})
        return res
        
IrModelAccess()<commit_msg>[FIX] in delete function report protector (lp:c2c-addons/6.1  rev 38)<commit_after># -*- encoding: utf-8 -*-
##############################################################################
#
#    Author <NAME>. Copyright Camptocamp SA
##############################################################################
from osv import fields, osv

class IrModelAccess(osv.osv):
    "We inherit ir model access to add specific write unlink and copy behavior"
    _name = 'ir.model.access'
    _inherit = "ir.model.access"
                    
    def _acces_can_be_modified(self, cr, uid, context=None):
        context = context or {}
        on = self.pool.get('ir.config_parameter').get_param(cr, uid, 'protect_security?', default=False, context=context)
        if on in (1, "1", "YES", True):
            if context.get('manual_security_override', False):
                return True
            return False
            
        else:
            return True
        
    def write(self, cr, uid, ids, vals, context=None):
        res =True
        context = context or {}
        if self._acces_can_be_modified(cr, uid, context=context):
            res = super(IrModelAccess, self).write(cr, uid, ids, vals, context=context)
        return res


    def unlink(self, cr, uid, ids, context=None):
        res = True
        context = context or {}
        # I'm note sur about this one maybe we should do nothing
        if self._acces_can_be_modified(cr, uid, context=context): 
            vals = {'perm_read':False,
             'perm_write': False, 
             'perm_unlink': False,
             'perm_create': False}
            super(IrModelAccess, self).write(cr, uid, ids, vals, context=context)
        else: 
            res = super(IrModelAccess, self).unlink(cr, uid, ids, context=context)

        return res
        
IrModelAccess()
{'fraction_non_alphanumeric': 0.18424638866176068, 'fraction_numerical': 0.003270645952575634, 'mean_word_length': 2.3454876937101186, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4879172', 'n_tokens_mistral': 1024, 'n_tokens_neox': 975, 'n_words': 280}