@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. Netty 框架学习 —— 基于 Netty 的 HTTP/HTTPS 应用程序

    通过 SSL/TLS 保护应用程序 SSL 和 TLS 安全协议层叠在其他协议之上,用以实现数据安全.为了支持 SSL/TLS,Java 提供了 javax.net.ssl 包,它的 SSLConte ...

  2. 铂金07:整齐划一-CountDownLatch如何协调多线程的开始和结束

    欢迎来到<并发王者课>,本文是该系列文章中的第20篇. 在上一篇文章中,我们介绍了Condition的用法.在本文中,将为你介绍CountDownLatch的用法.CountDownLat ...

  3. Android系统编程入门系列之加载界面Activity

    上回说到应用初始化加载及其生命周期,在Android系统调用Applicaiton.onCreate()之后,继续创建并加载清单文件中注册的首个界面即主Activity,也可称之为入口界面.主Acti ...

  4. .NET 云原生架构师训练营(设计原则与模式)--学习笔记

    在复杂系统的架构设计中引入设计原则与模式,能够极大降低复杂系统开发.和维护的成本 目录 几个问题 为什么要学习设计模式 优良架构设计的具体指标 理解复杂系统 面向对象思想(指导复杂系统的分析.设计.实 ...

  5. 美化terminal时碰到的问题- Set-Theme

    报错: 1 Set-Theme Set-Theme: The term 'Set-Theme' is not recognized as a name of a cmdlet, function, s ...

  6. Oracle查询wm_concat返回[oracle.sql.CLOB@7D6414ed]之坑!

    在orcale中使用wm_concat函数将字段分组连接. 在linux环境下需要将wm_concat(字段)进行to_char(wm_concat(字段))处理.

  7. 1、springcloud gateway

    参考: https://www.cnblogs.com/babycomeon/p/11161073.html 1.springcloud gateway1.1.依赖-初体验https://www.cn ...

  8. 使用Docker的同学注意了,这10个坑小心中招了

    Docker容器优点容器已经成为企业IT基础设施中必不可少的部分,它具有许多的优点,比如: 1 容器是不可变的--操作系统,库版本,配置,文件夹和应用程序都包装在容器内.你保证在质量检查中测试过的同一 ...

  9. Java | 方法的定义 & 重载 & 递归

    方法 方法就是一段用来完成特定功能的代码片段.   方法用于定义该类或该类的实例的行为特征和功能实现.方法是类和对象行为特征的抽象.在面向对象中,整个程序的基本单位是类,方法是从属于类和对象的. 方法 ...

  10. VMware Esxi开通SSH功能

    ESXi 5.5是直接安装在物理主机上的一个虚拟机系统,本质上是一个Linux系统.平时可以通过VMware Client端或者VMware vCenter进行管理,但对于一些特殊的VMware命令或 ...