This question has been flagged
4 Replies
6108 Views

I want to grant a user the create right on model crm.claim, but I don't want him to duplicate his claim. So on the more options tab, I want to hide "Duplicate", when the user is on the form view.

I know there is a relationship between the acess rights, and the options displayed on the More options selection, so, I'm trying to grant the create right without the duplicate right. How can I do it ?

Avatar
Discard
Best Answer

Take a look at this blog 

How to hide an options from 'More' button?
 
https://odooforbeginnersblog.wordpress.com/2017/06/11/how-to-hide-an-options-in-more-button/
Avatar
Discard
Best Answer

With only access rights, it is not possible to hide "Duplicate" button in more.  Instead you could try to raise an error when the user containing a particular group does duplicate.

    def copy(self, cr, uid, id, default=None, context=None):
        if self.pool.get('res.users').has_group(cr, uid, 'MODULE_NAME.YOUR CUSTOM GROUP ID'): # e.g. base.group_sale_manager
            raise orm.except_orm('Error', 'You cannot duplicate this record')
        return super(crm_claim, self).copy(cr, uid, id, default, context=context)

Avatar
Discard
Author

It's great on the python side, is there any similar solution, on XML side, like hiding the other options button, when a form view is loaded ? could it be done by xml or javascript ?

Hi, currently not in xml, button Duplicate is defined in javascript and depends create rights, see : addons/web/static/src/js/view_forms.js : self.is_action_enabled('create') && { label: _t('Duplicate'), callback: self.on_button_duplicate }, you should override this javascript file for that. Bye