跳至内容
菜单
此问题已终结
4 回复
8738 查看

Hi, 

Please i have a form with this workflow [ In progress, Finished ]

 i want to hide the create button when the workflow is in progress, and show it when we move the workflow to the finished.
in idoo 10


Regards,

形象
丢弃

try to create a access rule for this

编写者

i can hide the create button by using the access rule, but i what i'm looking for is for that the same user can use the create button until the workflow for the last record is in finished

create a record rule with your condition eg domain= [('state', '=', 'progress')] and create= false

最佳答案

This is the better way I cant find to hide create button bassed in some condition:

def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False):
res = super(Entity, self).fields_view_get(cr, uid, view_id=view_id, view_type=view_type,
context=context,
toolbar=toolbar, submenu=submenu)
doc = etree.XML(res['arch'])
if view_type == 'form' and [some_condition]:
for node_form in doc.xpath("//form"):
node_form.set("create", 'false')

res['arch'] = etree.tostring(doc)
return res
形象
丢弃
编写者

Hi,

I think this is not writting in odoo 10 ?

Ahh ok, in odoo 10 this is the source code:

@api.model

def fields_view_get(self, view_id=None, view_type='form', toolbar=False, submenu=False):

res = super(Entity, self).fields_view_get(view_id=view_id, view_type=view_type,

context=context,

toolbar=toolbar, submenu=submenu)

doc = etree.XML(res['arch'])

if view_type == 'form' and [some_condition]:

for node_form in doc.xpath("//form"):

node_form.set("create", 'false')

res['arch'] = etree.tostring(doc)

return res

Thanks man ! you gave me the idea and it works !

Thank you all!