Overslaan naar inhoud
Menu
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Deze vraag is gerapporteerd
4 Antwoorden
8734 Weergaven

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,

Avatar
Annuleer

try to create a access rule for this

Auteur

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

Beste antwoord

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
Avatar
Annuleer
Auteur

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!