码迷,mamicode.com
首页 > 其他好文 > 详细

OpenERP-隐藏多对多域弹出列表视图的"新建"按钮(Hide the "Create" button from the popup list view of a many2many field)

时间:2014-08-06 01:59:20      阅读:273      评论:0      收藏:0      [点我收藏+]

标签:java   io   文件   for   ar   cti   代码   html   

隐藏多对多域的弹出列表视图中的“新建”按钮,如例:

Hiding the "Create" button from the popup list view of a many2many field. Example shown as below:


1. 在.py文件中定义many2many的field:

1. Define a many2many field in the python source file

'a_m2m_field': fields.many2many('test2', 'test1_test_rel', 'test1_id', 'test2_id', string='M2M Field'),

2. 修改view_form.js,在大约4939行的位置,添加"var ctx = ..."至代码结尾的内容:

2. Modify the file view_form.js, insert the code from "var ctx = ..." to the end of code at about line 4939:

var $cbutton = self.$buttonpane.find(".oe_selectcreatepopup-search-create");
$cbutton.click(function() {
    self.new_object();
});
var ctx = self.context.__contexts[0];
if(typeof(ctx) == "string"){
    var ctxStr = ctx.replace("'", "\"", 'g');
    var context = JSON.parse(ctxStr);
    if(context.my_no_create && context.my_no_create != 0){
        $cbutton.remove();
    }
}

3. 修改XML文件,添加context:

3. Modify the XML file to add the context:

<field name="a_m2m_field" context="{'my_no_create': 1}">



OpenERP-隐藏多对多域弹出列表视图的"新建"按钮(Hide the "Create" button from the popup list view of a many2many field),布布扣,bubuko.com

OpenERP-隐藏多对多域弹出列表视图的"新建"按钮(Hide the "Create" button from the popup list view of a many2many field)

标签:java   io   文件   for   ar   cti   代码   html   

原文地址:http://blog.csdn.net/poluoge/article/details/38392691

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!