@api.multi
def button_cancel(self):
for move in self:
if not move.journal_id.update_posted:
raise UserError(_('You cannot modify a posted entry of this journal.\nFirst you should set the journal to allow cancelling entries.'))
# We remove all the analytics entries for this journal
move.mapped('line_ids.analytic_line_ids').unlink()
if self.ids:
self.check_access_rights('write') #调用函数
self.check_access_rule('write') #调用函数
self._check_lock_date()
self._cr.execute('UPDATE account_move '\
'SET state=%s '\
'WHERE id IN %s', ('draft', tuple(self.ids),))
self.invalidate_cache()
self._check_lock_date()
return True


@api.model
def check_access_rights(self, operation, raise_exception=True):
""" Verifies that the operation given by ``operation`` is allowed for
the current user according to the access rights.
"""
return self.env['ir.model.access'].check(self._name, operation, raise_exception) @api.multi
def check_access_rule(self, operation):
""" Verifies that the operation given by ``operation`` is allowed for
the current user according to ir.rules. :param operation: one of ``write``, ``unlink``
:raise UserError: * if current ir.rules do not permit this operation.
:return: None if the operation is allowed
"""
if self._uid == SUPERUSER_ID:
return invalid = self - self._filter_access_rules(operation) # ???????
if not invalid:
return forbidden = invalid.exists()
if forbidden:
# the invalid records are (partially) hidden by access rules
if self.is_transient():
raise AccessError(_('For this kind of document, you may only access records you created yourself.\n\n(Document type: %s)') % (self._description,))
else:
_logger.info('Access Denied by record rules for operation: %s on record ids: %r, uid: %s, model: %s', operation, forbidden.ids, self._uid, self._name)
raise AccessError(_('The requested operation cannot be completed due to security restrictions. Please contact your system administrator.\n\n(Document type: %s, Operation: %s)') % \
(self._description, operation)) # If we get here, the invalid records are not in the database.
if operation in ('read', 'unlink'):
# No need to warn about deleting an already deleted record.
# And no error when reading a record that was deleted, to prevent spurious
# errors for non-transactional search/read sequences coming from clients.
return
_logger.info('Failed operation on deleted record(s): %s, uid: %s, model: %s', operation, self._uid, self._name)
raise MissingError(_('Missing document(s)') + ':' + _('One of the documents you are trying to access has been deleted, please try again after refreshing.'))

odoo检查规则的更多相关文章

  1. Odoo 路线规则实现机制浅析

    事情是这个样子的:项目在实施过程中,碰到A仓库向B仓库供货的情况,心想这还不简单,老老实实地建多个仓库并将B仓库的供货仓库选为A仓库,再设置好产品的再订购规则,万事大吉了.然而,事情并非想象的那么简单 ...

  2. CheckStyle检查规则中文翻译

    本文主要介绍CheckStyle 的各个规则配置项目,这个版本的CheckStyle将样式规则分为了以下十六种类型共138条规则: 官方文档地址:http://checkstyle.sourcefor ...

  3. Springboot监控之一:SpringBoot四大神器之Actuator之2--覆盖修改spring cloud的默认的consul健康检查规则

    微服务网关是socket长连接与支付公司对接,该网关需要提供http接口给内部系统调用,当socket没有建立连接时(网关服务的高可用是haProxy搭建的,有些服务的socket可能未连上支付公司) ...

  4. 转!!Java代码规范、格式化和checkstyle检查配置文档

    为便于规范各位开发人员代码.提高代码质量,研发中心需要启动代码评审机制.为了加快代码评审的速度,减少不必要的时间,可以加入一些代码评审的静态检查工具,另外需要为研发中心配置统一的编码模板和代码格式化模 ...

  5. Drools规则

    1.实现业务逻辑和业务规则的分离,实现业务规则的集中管理 2.可以动态的改变业务规则,从而快速响应需求变更 3.业务分析人员也可以参与编辑.维护系统的业务规则 fact:一个普通的JavaBean插入 ...

  6. Java代码规范、格式化和checkstyle检查配置文档

    http://www.blogjava.net/amigoxie/archive/2014/05/31/414287.html 文件下载: http://files.cnblogs.com/files ...

  7. VIM 语法检查

    VIM Grammar Check 一.Language Tool Create by Dominique Pellé REFER:LanguageTool wikipedia REFER:Langu ...

  8. 很详细、很移动的Linux makefile教程:介绍,总述,书写规则,书写命令,使用变量,使用条件推断,使用函数,Make 的运行,隐含规则 使用make更新函数库文件 后序

    很详细.很移动的Linux makefile 教程 内容如下: Makefile 介绍 Makefile 总述 书写规则 书写命令 使用变量 使用条件推断 使用函数 make 的运行 隐含规则 使用m ...

  9. DevCloud让代码检查更科学

    代码检查是软件开发工作中不可或缺的一部分,众所周知,规范化的编码是一个优质项目的保证.华为软件开发云(DevCloud)便提供了专业科学的自动化代码检查工作. 一.华为软件开发云(DevCloud)目 ...

随机推荐

  1. 【NX二次开发】Block UI 分割线

    设置控件可见 this->separator0->GetProperties()->SetLogical("Show",true);

  2. NX二次开发-获取面的外围边和孔槽边

    函数: UF_MODL_ask_face_loops()  获取面的所有封闭边组合(多组edge) UF_MODL_ask_loop_list_count() 获取loop的数量(面上孔.槽的数量+1 ...

  3. Spring Boot WebFlux-06——WebFlux 整合 Redis

    第06课:WebFlux 整合 Redis 前言 上一篇内容讲了如何整合 MongoDB,这里继续讲如何操作 Redis 这个数据源,那什么是 Reids? Redis 是一个高性能的 key-val ...

  4. c#json将字符串反序列化成对象时不新建类的做法

    在服务端代码文件中加上struct结构体就能解决 struct LocationInfo { public string LocationID { get; set; } public string ...

  5. 三剑客-awk

    1.作用特点 排除信息 查询信息 统计信息 替换信息 2.语法格式 awk [参数] '模式-动作' 文件 3.awk命令执行原理 4.命令使用方法 创建测试环境 [root@shuai ~]# ca ...

  6. 03 jumpserver用户管理

    3.用户管理: (1)创建用户组: (2)创建用户并加入组: (3)用户通过邮件链接修改密码:

  7. Vue 动态组件和异步组件

    基础案例 动态组件切换类比"bilibili-个人中心"的横向菜单切换不同的标签页的功能. 在Vue中可以使用 component 标签,并加一个特殊的属性(attribute) ...

  8. (数据科学学习手札124)pandas 1.3版本主要更新内容一览

    本文示例代码及文件已上传至我的Github仓库https://github.com/CNFeffery/DataScienceStudyNotes 1 简介 就在几天前,pandas发布了其1.3版本 ...

  9. Java程序设计(2021春)——第一章续笔记与思考

    Java程序设计(2021春)--第一章续笔记与思考 目录 Java程序设计(2021春)--第一章续笔记与思考 Java数据类型 基本数据类型 引用类型 基本数据类型--整数类型的细节 基本数据类型 ...

  10. docker配置redis6.0.5集群

    docker配置redis6.0集群方案 docker安装 请直接挂载课程配套的Centos7.x镜像, docker官方建议使用CentOS7 (1)yum 包更新到最新 sudo yum upda ...