Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

1

Hide duplicate option on "More Options" selection, on form view

By
Yassine TEIMI
on 4/3/15, 6:08 AM 852 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 ?

0

Atchuthan - Technical Consultant, Sodexis Inc

--Atchuthan - Technical Consultant, Sodexis Inc--
3883
| 5 3 8
Puducherry, India
--Atchuthan - Technical Consultant, Sodexis Inc--
Passionate coder in Python/Odoo(formerly known as OpenERP).

Contact me via GMail: atchuthantu@gmail.com via Skype: atchuthan_skype
via Linkedin: http://in.linkedin.com/in/atchuthantu
Atchuthan - Technical Consultant, Sodexis Inc
On 4/3/15, 6:26 AM

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)

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 ?

Yassine TEIMI
on 4/3/15, 8:03 AM

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

Cyril Gaspard (GEM)
on 4/4/15, 8:57 AM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

2 follower(s)

Stats

Asked: 4/3/15, 6:08 AM
Seen: 852 times
Last updated: 4/3/15, 6:26 AM