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

Hide a fields when part of a group

By
Mathieu Laflamme
on 2/9/16, 6:48 PM 754 views

There are many example of fields visible only when the user is part of a group like this line of code from mrp module.

<field name="product_uom" class="oe_inline" readonly="1" groups="product.group_uom"/>

How can we do the opposite?????? I want to hide a field when part of a group.


To be more specific, my module is adding an option to use pounds as UoM for weight for product. Odoo only handle KG and as much as I like the international system, we mainly use pounds here in Canada! So my module will hide the weight field and show weight_lb instead. The showing was easy, but hiding the first, not so much...

1

Ankit H Gandhi(AHG)

--Ankit H Gandhi(AHG)--
996
| 5 3 6
Rajkot, India
--Ankit H Gandhi(AHG)--

Learning Python..

Ankit H Gandhi(AHG)
On 2/10/16, 4:25 AM

Dear Mathieu,

Yes, You can do it.
First create your form view. Then inherit the view also specify the groups.
For example in sale order form view, i want to make the customer reference field invisible for group user.

<record id="view_order_form_cust_ref_readonly" model="ir.ui.view">
    <field name="name">sale.order.form.readonly.cust</field>
    <field name="model">sale.order</field>
    <field name="inherit_id" ref="sale.view_order_form"/>
    <field name="groups_id" eval="[(6, 0, [ref('base.group_user') ])]"/>
    <field name="arch" type="xml">
        <field name='client_order_ref'" position="attributes">
            <attribute name="invisible">1</attribute>
        </field>
    </field>
</record>

Hope above code help for you.

Best Regards,

Ankit H Gandhi.

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: 2/9/16, 6:48 PM
Seen: 754 times
Last updated: 2/10/16, 10:33 AM