(49) odoo context操作
* context
这是一个上下文,运用很灵活
* 得到整个context
V7
context=dict(context or {})
这个版本是明传
V8
self.context_get()
self.env['res.users'].context_get()
* 得到context里面对应的值
得到flag的值
V8
self.env.context.get('flag',False)
V7
context.get('flag',False)
* 修改context里面的对应的值
V8
self.with_context({'flag': False})
或
self.with_context(flag=True) 单一时
或
ctx = dict(context or {})
ctx['flag']=False
self.with_context(ctx)
v7
context = dict(context or {})
这句不在改前一定要有,否则报错
-------
context.update({'flag': False})
或:
context.update(flag=True)单一时
或:
context['flag']=False
* 保证context的字典类型
context = dict(context or {})
* 复制context
c = context.copy()
主要改变部分值,带到其它函数中
* 自己构造context
context = {'flag':Fasle,'lang':'zh_cn'}
* 常规用法
v7 带入函数中
def create(self, cr, uid, vals, context=None):
context = dict(context or {})
v8 带入函数中
if part.lang:
self = self.with_context(lang=part.lang)
product = self.env['product.product'].browse(product)
------
return self.with_context(ctx).write({'invoice_line': []})
记住,用了 with_context
* 视图中引入context
model="ir.actions.act_window"时
<field name="context">{"search_default_my_export_list":1} </field>
代表 搜索时 my_expert_list 值为1 对于 search_default_是系统的前置标识
分组
<filter string="Day"name="group_day"context="{'group_by':'date_start:day'}"
指定搜索
<field name="department_id" string="Department" context="{'invisible_department': False}"/>
列表中字段
<field name="line_ids" context="{'currency_id': currency_id,
'default_analytic_account': context.get('analytic_account', '')}">
视图定义context 带入函数
<field name="product_id" on_change="onchange_product_id(product_id, context)"
context="{'default_hr_expense_ok':1}"/>
* context上面是常用的方法,掌握后,就可以在整个系统中方便传数值,但是上下文,不要传太多
(49) odoo context操作的更多相关文章
- (47) odoo详细操作手册
odoo 8 详细操作手册, ERP(Odoo8.0)操作手册-v1.10(陈伟明).pdf 链接: http://pan.baidu.com/s/1hsp0bVQ 密码: r9tt 花了将近9个月时 ...
- (10)odoo控制器操作
-----------------更新时间11:17 2016-09-18 星期日 完善讲解17:44 2016-02-17 星期三-----------------* 控制器Controlle ...
- (04)odoo视图操作
-----------------更新时间19:04 2016-09-29 星期四11:17 2016-09-18 星期日18:13 2016-04-05 星期二15:05 2016-03-14 星期 ...
- odoo - context
得到整个context self.context_get() self.env['res.users'].context_get() 得到context里面对应的值 eg:得到flag的值 self. ...
- 第一章 使用开发者模式快速入门 Odoo 12
本文为最好用的免费ERP系统Odoo 12开发手册系列文章第一篇. Odoo提供了一个快速应用开发框架,非常适合创建商业应用.这类应用通常用于保留业务记录,增删改查操作.Odoo 不仅简化了这类应用的 ...
- Odoo Shell
Odoo shell 提供了一个简便的操作 Odoo的交互界面, 从 odoo 9.0 开始就是标准功能, 无需安装第三方应用. 本文基于Odoo10 说明 Odoo Shell以及 Odoo Mod ...
- 第三章 Odoo基本设置
登录 正常访问http://localhost:8069后,登录的界面如下: 这是Odoo默认的认证方式,也是我们最常见最熟悉的认证方式,7.0以前,数据库中的密码都是以明文方式存储,可以很轻松地在r ...
- Android Context完全解析
Context类型 我们知道,Android应用都是使用Java语言来编写的,那么大家可以思考一下,一个Android程序和一个Java程序,他们最大的区别在哪里?划分界限又是什么呢?其实简单点分析, ...
- Android各种获取Context方法
首先讲一讲这四个函数的区别,后面还有我对context的一些理解区别如下所示: 原文链接http://stackoverflow.com/questions/6854265/getapplicatio ...
随机推荐
- Gap Buffer
From codeproject: http://www.codeproject.com/Articles/20910/Generic-Gap-Buffer
- 了解FreeRTOS源文件目录结构
参考文献: Understanding the FreeRTOS directory structure. 从官网下载下来的FreeRTOS源文件包,对于每一个已经移植完成的处理器,都有一个与之对应的 ...
- java 编译期常量
今天在看书的时候遇到了一个不是很懂的名词,是在think in java 这本书的第七章讲final关键字时讲到的.然后自己在网上查了一下知道了一些. 编译器常量就是:它的值在编译期就可以确定的常量. ...
- 1,Boost -> Bind
#include <boost/bind.hpp> #include <boost/shared_ptr.hpp> #include <iostream> usin ...
- QFile QDataStream QTextStream
#include <QCoreApplication> #include <QMap> #include <QFile> #include <QDir> ...
- webstorm IDE添加Plugins----添加vue插件
webstorm IDE很强大了,扩展性很强,语法校验很强大,不过有时候一些特殊的插件 还是需要自己添加到IDE的 下面以添加VUE Plugins 为例: Setting--Plugins[点下方 ...
- Web Api 简介
ASP.NET Web API 简介 ASP.NET MVC 4 包含了 ASP.NET Web API, 这是一个创建可以连接包括浏览器.移动设备等多种客户端的 Http 服务的新框架, ASP. ...
- 外国javascript资源搜索
https://www.javascripting.com/search?q=canvas
- Netsuite > Employee Record Name维护规则
Employee Record Name 维护规则 - 在NS系统设计中,默认的Field展现是:First Name, Middle Name, Last Name - 在General Prefe ...
- mate 标签的 http-equiv
http-equiv 1. 页面的描述 <meta http-equiv="description" content="This is my page"& ...