Skip to Content
Меню
Вам необхідно зареєструватися, щоб взаємодіяти зі спільнотою.
Це запитання позначене
4 Відповіді
8715 Переглядів

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!