0

I have hided the create button using following view,

<tree create="false" edit="false" >

It is working perfect, But I need to hide the create button dynamic way like this,

<tree attrs="{'create':[("uid",'=',1)]}" edit="false" >

But it is not working.

codeimplementer
  • 3,303
  • 2
  • 14
  • 16

4 Answers4

3

For making create button invisible only for uid=1 its better to write access record rules.

If you want to make create button invisible for a particular group then inherit the original view and specify group for the inherited view, then specify create="false" attribute to the tree view. Click on this for Example.

Community
  • 1
  • 1
OmaL
  • 5,037
  • 3
  • 31
  • 48
0

Your idea is nice, but 'create' unfortunately is not implemented within attrs-attribute.

A bit of a workaround would be your first option + a new create button implemented by yourself, but i thinks that's a bit tricky and i can't say if that is 100% possible.

CZoellner
  • 13,553
  • 3
  • 25
  • 38
0

you can not use attrs in tree view create option

Why not you used object access rights things in this. create, delete, read, unlink, only give create right to those users whom have rights to create

please refer this answer: OpenERP 7 Access Rights for User Roles

Regards,

Community
  • 1
  • 1
user1576199
  • 3,217
  • 3
  • 20
  • 32
0

You can use this method and replace the class name...

def unlink(self, cr, uid, ids, context=None):
    if context is None:
        context = {}
    for rec in self.browse(cr, uid, ids, context=context):
        if rec.state not in ['draft', False]:
            raise osv.except_osv(_('Invalid Action!'), _('Cannot delete a record which is in state \'%s\'.') %(rec.state,))
    return super(purchase_order, self).unlink(cr, uid, ids, context=context)
Nazar
  • 101