OpenERP-隐藏多对多域弹出列表视图的"新建"按钮(Hide the "Create" button from the popup list view of a many2many field)
2014-08-05 23:33
399 查看
隐藏多对多域的弹出列表视图中的“新建”按钮,如例:
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
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:
3. 修改XML文件,添加context:
3. Modify the XML file to add the context:
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}">
相关文章推荐
- 【WPF收藏】隐藏TabControl标签(按钮)的方法(Hide the TabStrip of a TabControl)
- 解决在eclipse中配置Tomcat时,出现"Cannot create a server using the selected type"的错误
- openerp学习笔记 视图(tree\form)中隐藏按钮( 创建、编辑、删除 ),tree视图中启用编辑
- "Your computer could not be joined to the domain. You have exceeded the maximum number of computer accounts you are allowed to create in this domain. Contact your system administrator to have this limit reset or increased."
- "could not create the java virtual machine"启动eclipse报错
- eclipse启动时弹出"Failed to create the Java Virtual Machine"解决办法
- [问题解决] "Nautilus could not create the required folder "/home/kenneth/.config/nautilus"
- "could not create the java virtual machine"启动eclipse报错 --
- openerp学习笔记 视图样式(表格行颜色、按钮,字段只读、隐藏,按钮状态、类型、图标、权限,group边距,聚合[合计、平均],样式)
- Dynamics CRM 365 子网格上"添加"按钮旁的“查看关联视图”按钮如何控制显示和隐藏?
- 打开Eclipse时出现"Failed to create the Java Virtual Machine"
- 解决浏览器弹出 安全警告"当前网页正在视图打开您的受信任的站点列表中的站点,您想允许这样做吗?"
- "could not create the java virtual machine"启动eclipse报错
- 对于一个"ul"列表,单击弹出每个"li"对应的索引
- 打开Eclipse时出现"Failed to create the Java Virtual Machine"怎么办?
- [Drupal 7]How to hide the "URL path settings" fieldset?如何隐藏“URL别名”字段?
- 打开Eclipse时出现"Failed to create the Java Virtual Machine" 的处理
- How to hide the create button dynamical tree view in openerp ?
- 隐藏ps -ef命令中看到的密码(Hide the password that from the " ps -ef " command)
- 使用MagicAJax的AjaxPanel时有时会弹出"Using the AjaxCallHelper write methods outside of an AjaxCall is not allowed."