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.

0

How to make a field invisible for certain groups

By
Shawn Varghese
on 7/6/15, 5:30 AM 2,384 views

This question seems to have been asked before, but I couldn't get the answers to work.

I have a field - amount_words. It should be invisible only to one group and visible to all others. This is what I have done so far:

 <record id="view_order_line_tree2" model="ir.ui.view">
    <field name="name">sale.order.line.tree.inherit</field>
    <field name="model">sale.order</field>
    <field name="inherit_id" ref="sale.view_order_form"/>
    <field name="arch" type="xml">
        <xpath expr="//page/group" position="after"> <group class="oe_subtotal_amount_footer oe_left"> <field name="amount_words" /> </group> </xpath> </field> </record>

This is to introduce the amount_words field.

Now, to hide it for the service_order group:

 <record id="view_order_line_tree3" model="ir.ui.view">
    <field name="name">sale.order.line.tree.inherit2</field>
    <field name="model">sale.order</field>
    <field name="inherit_id" ref="view_order_line_tree2"/>
    <field name="groups_id" eval="[(6, 0, [ref('custom_sale.group_service_order') ])]"/>
    <field name="arch" type="xml">
	<field name="amount_words" position="attributes">
	    <attribute name="attrs">{'invisible':1}</attribute>
	</field>
    </field>
</record>

But the effect is that it is now invisible for all groups. Does anyone know how to achieve this?



1
Kalpana Hemnani
On 7/6/15, 12:06 PM


Hello Shawn,

You can use 'groups' for number of groups you want to show this field just like below:

<field name="amount_words" position="attributes">

    <attribute name="groups">other_than_service_order_group_name</attribute>

</field>

After doing this, field will only be seen to groups you have mentioned in group attribute.

Hope this helps!

Thanks,

Kalpana Hemnani

 

Thanks Kalpana, but here I would have to assign the majority of my users to a separate group which seems unnecessary. I have commented in the other post. Please let me know in case you have any other suggestions.

Shawn Varghese
on 7/6/15, 12:49 PM
0
Farid Ghanchi
On 7/7/15, 2:14 AM

Dear Shawn,

You can create a new wizard, And in this wizard you can choose a User/Customer (Specific User) and on this User/Customer give a access to this new field is visible or invisible. 

Thanks.

Farid Ghanchi

0

Solanki Shamji

--Solanki Shamji--
1293
| 5 2 6
Baroda, India
--Solanki Shamji--

Hello!

Solanki Shamji
On 7/6/15, 11:35 AM

Hello,

Please check the this url.

http://pinakinnayi.blogspot.in/2013/06/field-level-security-in-openerp.html

Hope this will help you.

Thanks.

Shamji


Thanks Solanki, but I think the link describes how to display it for a certain group. In my case, there are only very few users who should not see the field, so I created a group for that purpose. The workaround would be to create a separate group, assign everyone else to that group and apply groups to that. But that would be a tedious task and not the ideal way to do it. I think the code snippet that I posted with some tweaks should accomplish the task. Please let me know if you have any other ideas.

Shawn Varghese
on 7/6/15, 12:47 PM

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

1 follower(s)

Stats

Asked: 7/6/15, 5:30 AM
Seen: 2384 times
Last updated: 7/7/15, 2:14 AM