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

Show edit button to specific user

By
Luis Filipe Castanheira
on 3/13/14, 12:00 PM 1,819 views

Hi, I would like to show the edit button to ONE specific user (in this case, not to whole group) on a module I am developing.

Imagine, for example that I have some request. In order to go through the process to that request, I need to ask the opinion of one specific user on that subject (an expert / consultant on that subject. That user might not even be administrator!). I have the identification on the user / consultant that will be emitting his opinion stored in my model.

How can I show the edit / save button on form view to that specific user and all other users will have read only access.

I am working on OpenERP V7.0 Thanks in advance! -FC.

1

Solved it creating a XML file with domain rules. I'll leave here a sample for future reference, in case someone has the same problem.

<?xml version="1.0"?>
<openerp>
    <data>
        <!-- everyone can see issued opinions, but can't edit them -->
        <record id="processos_uc_see_issued_opinions_rule" model="ir.rule">
            <field name="name">See issued opinions rule</field>
            <field name="model_id" ref="model_opinion"/>
            <field name="domain_force">[('state','=','issued')]</field> 
            <field name="perm_read" eval="True"/> <!-- can see -->
            <field name="perm_write" eval="False"/> <!-- can't change it -->
            <field name="perm_unlink" eval="False"/>
            <field name="perm_create" eval="False"/>             
            <field name="global" eval="0" />
            <field name="groups" eval="[(6,0,[ref('processos_uc.group_processos_user')])]"/>        
        </record>

        <!-- consultant can see and edit his opinion requests -->
        <record id="processos_uc_see_own_opinions_rule" model="ir.rule">
            <field name="name">See own opinions rule</field>
            <field name="model_id" ref="model_opinion"/>
            <field name="domain_force">['|',('consultant_uid','=',user.id),('consultant_uid','=',False)]</field> 
            <field name="perm_read" eval="True"/>
            <field name="perm_write" eval="True"/>
            <field name="perm_unlink" eval="True"/>
            <field name="perm_create" eval="True"/>             
            <field name="global" eval="0" />
            <field name="groups" eval="[(6,0,[ref('processos_uc.group_processos_user')])]"/>        
        </record>

        <!-- requestor can see and edit opinion requests while they're draft -->
        <record id="processos_uc_create_draft_opinions_rule" model="ir.rule">
            <field name="name">Create opinions rule</field>
            <field name="model_id" ref="model_opinion"/>
            <field name="domain_force">['&',('state','=','requested'),'|',('requestor','=', user.id),('requestor','=', False)]</field> 
            <field name="perm_read" eval="True"/>
            <field name="perm_write" eval="True"/>
            <field name="perm_unlink" eval="True"/>
            <field name="perm_create" eval="True"/>             
            <field name="global" eval="0" />
            <field name="groups" eval="[(6,0,[ref('processos_uc.group_processos_user')])]"/>        
        </record>

        <!-- managers can do anything! -->
        <record id="processos_uc_managers_can_do_anything_rule" model="ir.rule">
            <field name="name">Managers can do anything rule</field>
            <field name="model_id" ref="model_opinion"/>
            <field name="domain_force">[(1,'=',1)]</field> <!-- can do anything! -->
            <field name="perm_read" eval="True"/>
            <field name="perm_write" eval="True"/>
            <field name="perm_unlink" eval="True"/>
            <field name="perm_create" eval="True"/>             
            <field name="global" eval="0" />
            <field name="groups" eval="[(6,0,[ref('processos_uc.group_processos_manager')])]"/>        
        </record>

     </data>
</openerp>

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

0 follower(s)

Stats

Asked: 3/13/14, 12:00 PM
Seen: 1819 times
Last updated: 3/16/15, 8:10 AM