This question has been flagged
3 Replies
10965 Views

Hi, I have a module in wich everybody has read permissions, but only some users belonging to a group are allowed to take actions. So I would like to show my workflow buttons only to these users.

I tryed to add the groups="group_name" attribute to the button, but I when I update my module I get an Arch Error. What is the right way to do this?

EDIT - Question Reformulation!
________________________________________________________________________

Thanks for your answers, but it is not what I was looking for. I know that adding the "groups" attribute to a field, it hides it from users that don't belong to that group. My question was if there is anything similar to buttons.

If I have this code on my xml <button name="wtv" string="whatever" groups="my_group" /> it rises a "Invalid XML for View Architecture", so I guess this isn't a valid option for buttons.

The full trace like this:

2014-05-21 14:15:06,455 13905 INFO may_9 openerp.modules.loading: module processos_uc: loading processos_view.xml
2014-05-21 14:15:06,493 13905 ERROR may_9 openerp.addons.base.ir.ir_ui_view: Can't render view processos_uc.view_generic_request_form for model: generic.request
Traceback (most recent call last):
  File "/opt/openerp/v7/server/openerp/addons/base/ir/ir_ui_view.py", line 126, in _check_render_view
    fvg = self.pool.get(view.model).fields_view_get(cr, uid, view_id=view.id, view_type=view.type, context=context)
  File "/opt/openerp/v7/server/openerp/osv/orm.py", line 2262, in fields_view_get
    xarch, xfields = self.__view_look_dom_arch(cr, user, result['arch'], view_id, context=ctx)
  File "/opt/openerp/v7/server/openerp/osv/orm.py", line 1915, in __view_look_dom_arch
    fields_def = self.__view_look_dom(cr, user, node, view_id, False, fields, context=context)
  File "/opt/openerp/v7/server/openerp/osv/orm.py", line 1861, in __view_look_dom
    fields.update(self.__view_look_dom(cr, user, f, view_id, in_tree_view, model_fields, context))
  File "/opt/openerp/v7/server/openerp/osv/orm.py", line 1861, in __view_look_dom
    fields.update(self.__view_look_dom(cr, user, f, view_id, in_tree_view, model_fields, context))
  File "/opt/openerp/v7/server/openerp/osv/orm.py", line 1822, in __view_look_dom
    if not check_group(node):
  File "/opt/openerp/v7/server/openerp/osv/orm.py", line 1730, in check_group
    context=context)
  File "/opt/openerp/v7/server/openerp/osv/orm.py", line 1681, in user_has_groups
    for group_ext_id in groups.split(',')])
  File "/opt/openerp/v7/server/openerp/addons/base/res/res_users.py", line 508, in has_group
    assert group_ext_id and '.' in group_ext_id, "External ID must be fully qualified"
AssertionError: External ID must be fully qualified
2014-05-21 14:15:06,496 13905 ERROR may_9 openerp.tools.convert: Parse error in /home/lfc/openerp/v7/addons/processos_uc/processos_view.xml:31:

(...)
EXTRACT OF MY XML HERE
(...)

Traceback (most recent call last):
  File "/opt/openerp/v7/server/openerp/tools/convert.py", line 847, in parse
    self._tags[rec.tag](self.cr, rec, n)
  File "/opt/openerp/v7/server/openerp/tools/convert.py", line 814, in _tag_record
    id = self.pool.get('ir.model.data')._update(cr, self.uid, rec_model, self.module, res, rec_id or False, not self.isnoupdate(data_node), noupdate=self.isnoupdate(data_node), mode=self.mode, context=rec_context )
  File "/opt/openerp/v7/server/openerp/addons/base/ir/ir_model.py", line 937, in _update
    model_obj.write(cr, uid, [res_id], values, context=context)
  File "/opt/openerp/v7/server/openerp/addons/base/ir/ir_ui_view.py", line 214, in write
    return super(view, self).write(cr, uid, ids, vals, context)
  File "/opt/openerp/v7/server/openerp/osv/orm.py", line 4203, in write
    self._validate(cr, user, ids, context)
  File "/opt/openerp/v7/server/openerp/osv/orm.py", line 1546, in _validate
    raise except_orm('ValidateError', '\n'.join(error_msgs))
except_orm: ('ValidateError', u'Error occurred while validating the field(s) arch: Invalid XML for View Architecture!')
2014-05-21 14:15:06,500 13905 ERROR may_9 openerp.netsvc: ValidateError
Error occurred while validating the field(s) arch: Invalid XML for View Architecture!
Traceback (most recent call last):
  File "/opt/openerp/v7/server/openerp/netsvc.py", line 292, in dispatch_rpc
    result = ExportService.getService(service_name).dispatch(method, params)
  File "/opt/openerp/v7/server/openerp/service/web_services.py", line 626, in dispatch
    res = fn(db, uid, *params)
  File "/opt/openerp/v7/server/openerp/osv/osv.py", line 188, in execute_kw
    return self.execute(db, uid, obj, method, *args, **kw or {})
  File "/opt/openerp/v7/server/openerp/osv/osv.py", line 144, in wrapper
    raise except_osv(inst.name, inst.value)
except_osv: ('ValidateError', u'Error occurred while validating the field(s) arch: Invalid XML for View Architecture!')

Avatar
Discard
Best Answer

Try this in your xml file... <field name="name" groups="base.group_userB"/>. Now the userB group only can view the field....

Avatar
Discard
Best Answer


<button name="sapproved_button" string="Second Approval" type="object"
 class="btn-primary"  groups="GROUPNAME"/>


Avatar
Discard
Best Answer

Hello,

Maybe you typed a wrong group name , or maybe the group name is related to another module that is not referenced in the dependencies of  the __openerp__.py

example in a module :

<field groups="product.group_product_variant" name="variants"/>

You call the group "group_product_variant" that belongs to the module "product". So the __openerp__.py should have the module "product" in the "depends" declaration

In the same way, you must refer to this group by prefixing with the name of the module : product.group_product_variant

Avatar
Discard