得到整个context

  self.context_get()
self.env['res.users'].context_get()

得到context里面对应的值

  eg:得到flag的值

 self.env.context.get('flag',False)

修改context里面的对应的值

  self.with_context({'flag': False})

self.with_context(flag=True) 单一时

ctx = dict(context or {})
ctx['flag']=False
self.with_context(ctx)

保证context的字典类型
  context = dict(context or {})

复制context

c = context.copy()
  主要改变部分值,带到其它函数中

自己构造context

  context = {'flag':Fasle,'lang':'zh_cn'}

常规用法
  带入函数中

    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":} </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}"/>

many2one字段指定打开视图:

tree_view_ref,form_view_ref,……
<field name="stock_quant_id" required="" options="{'no_create_edit': True}" context="{'tree_view_ref':'tjc_stock.tjc_view_stock_quant_tree'}"/>

odoo - context的更多相关文章

  1. (49) odoo context操作

    * context  这是一个上下文,运用很灵活 * 得到整个context  V7  context=dict(context or {})  这个版本是明传  V8   self.context_ ...

  2. odoo 开发 context 上下文的用法

    context   这是一个上下文,运用很灵活  得到整个context   self.context_get() self.env['res.users'].context_get() 得到cont ...

  3. odoo里面context用法

    原文转自:https://www.cnblogs.com/zhaoweihang/p/9698852.html <field name="partner_id" string ...

  4. odoo开发笔记 -- context上下文

    字段级别 视图级别 窗口动作级别

  5. Odoo 二次开发教程(五)-新API的介绍与应用

    [关于odoo新API的介绍,Internet上资料很少,或者不够完整详实,这会对初学者造成很大的困惑,本篇的目的就是希望能帮助新手了解新API的大概] odoo 新api的实现是借助于python装 ...

  6. Odoo 二次开发教程(四)-只读、唯一性验证和ORM方法介绍

    一.只读和唯一性验证 只读的设置有两种方法,一种是实在字段定义时设置为只读,第二种是在页面视图中进行设置. 接前例,我们将学生(tech.student)的名字name字段设置成只读. 方法一:字段定 ...

  7. Odoo 中的 Controller

    来自  Odoo处理HTTP请求的接口用的Contoller类,封装于web模块中. --------------------------------------------------------- ...

  8. Displaying a full list of groups in Odoo's Kanban view

    Kanban view is probably the most flexible view in Odoo. It can be used for many different purposes. ...

  9. Odoo Many2many 指定默认分组过滤

    在odoo里如果想单击某个菜单打开的页面是自带过滤的,可以在打开菜单的动作中添加默认过滤来实现,今天有同学在群里问,如何在Many2many的添加更多的弹出窗口中添加类似的过滤,其实是非常非常简单的, ...

随机推荐

  1. 服务器内存占用不断的增加 & 任务管理器(PF使用率)不断的增加:关注句柄数

    最近一二个月以来,我发现服务器的内存占用正按着每天60M的速度增加. 一台windows 2003的服务器(2G内存),刚刚启起时占用内存:600M左右. 运行20天后,内存占用(PF使用):1.8G ...

  2. 【leetcode】 Merge Intervals

    Merge Intervals Given a collection of intervals, merge all overlapping intervals. For example,Given  ...

  3. java代码示例(4—1(作业))

    package com.java.union4; import static org.junit.Assert.*; import org.junit.Test; public class Demo ...

  4. Angular组件生命周期钩子

    Angular会按以下顺序依次调用以下钩子(8个): ngOnChanges ngOnInit ngDoCheck ngAfterContentInit ngAfterContentChecked n ...

  5. NFS无法启动解决方式

    今天一台挂载nfs磁盘的服务器出现异常,数据不能写入,执行 df -h 卡住不动. 登录nfs server查看发现nfs为启动. [root@server10-13 web]# exportfs [ ...

  6. 学习windows编程 day4 之 自定义映射

    LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { HDC hdc; PAINTSTRU ...

  7. mySQL数值类型的取值范围

    如下图,int最大为2145483647,手机号码应该用bigint

  8. MyBatis编写映射文件实现增删改操作 附说明及代码

    1.看一下我们接口 package cn.bdqn.mybatis.dao; import org.apache.ibatis.annotations.Select; import cn.bdqn.m ...

  9. leetCode- 472. Concatenated Words

    因为每个组合的字符串,至少要有3个index. 起点,中间拼接点,结点.所以可以将字符串分解为子字符串,判断子字符串是否存在.但是,后面字符串的存在必须要在前面字符串已经存在基础上判断. class ...

  10. Leanote 蚂蚁笔记 云笔记

    Leanote 蚂蚁笔记  1.Leanote 数据存储是使用mongo存放的,所以需要安装mongo包 1.MongoDB 数据存储 Leanote 依赖 MongoDB 作为数据存储,下面开始安装 ...