我在OpenERP_7上创建了一个按钮。它的基本用途是在树视图中打印选定的记录。它就像OpenERP-7中使用的更多按钮。我面临的问题是我不希望这个按钮显示在窗体视图上。现在它显示在树视图和窗体视图上但是我希望它只能在树视图上查看。因为它不是简单的按钮就是为什么我有问题。我是否必须在Web模块中进行更改,还是可以使用任何用户访问权限进行更改?我真的需要这方面的指导。 Plz指导我实现这一目标。
这是xml部分:
<?xml version="1.0" encoding="UTF-8"?>
<!-- vim:fdl=1:
-->
<templates id="template" xml:space="preserve">
<t t-name="AddPrintScreenMain">
<div class="oe_form_dropdown_section">
<button class="oe_dropdown_toggle oe_dropdown_arrow">Printscreen</button>
<ul class="oe_dropdown_menu">
<li class="oe_sidebar_printscreen_pdf"><span>PDF</span></li>
<li class="oe_sidebar_printscreen_xls"><span>Excel</span></li>
</ul>
</div>
</t>
</templates>
我做了这样的改动:
def fields_view_get(self, cr, uid, view_id=None, view_type='form',context=None, toolbar=False, submenu=False):
result = super(deg_form, self).fields_view_get(cr, uid, view_id,
view_type, context, toolbar, submenu)
if result.get("name") == u'deg.form':
doc = etree.XML(result['arch'])
modifiers = '{"invisible": true}'
nodes = doc.xpath("//button[@name='AddPrintScreenMain']")
for node in nodes:
node.set('modifiers', modifiers)
result['arch'] = etree.tostring(doc)
return result
答案 0 :(得分:0)
您需要做的是覆盖fields_view_get方法并执行以下操作:
from lxml import etree
def fields_view_get(self, cr, uid, view_id=None, view_type='form',
context=None, toolbar=False, submenu=False):
result = super(work_order, self).fields_view_get(cr, uid, view_id,
view_type, context, toolbar, submenu)
if result.get("name") == u'your.form.name.here':
doc = etree.XML(result['arch'])
modifiers = '{"invisible": true}'
nodes = doc.xpath("//button[@name='btn_name_here']")
for node in nodes:
node.set('modifiers', modifiers)
result['arch'] = etree.tostring(doc)
return result