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.

4

How to hide fields in OpenERP7

By
TestUser
on 4/2/13, 7:32 AM 8,061 views

I read the help about field-access-rights. (My karma is insufficient to publish links)

and thought it should work - but didn't.

I want to hide the product price to a specific user group. I just want to change the visibility to this one field. I don't want to change any python code or xml file. It worked in version 6.1 and in the link above it says it should also work in version 7.

So I opened the model for product in database structure and said edit... I clicked on the price field and I was able to add a user group for this price field. I saved the field (and it worked) but I still had to save the model but that doesn't work and the field change were undone. When I do this I get an error message saying: Properties of an elementary field can't be changed that way. Please do this by adapting your python code - ideally with your own modul.

Is it or is it not possible to change just a single fields visibility to a group... with no python code or xml changes...?

4

Francesco OpenCode

--Francesco OpenCode--
3608
| 5 7 9
Grottaglie, Italy
--Francesco OpenCode--

Italian Odoo (OpenERP) Modules Developer LINKEDIN: http://www.linkedin.com/in/francescoapruzzese

Francesco OpenCode
On 4/2/13, 8:57 AM

To show a field in relation of a group, you can use this code:

<xpath expr="//field[@name='order_line']/tree//field[@name='tax_id']" position="replace">
    <field name="company_id" groups="your_group"/>
</xpath>

Thank you too. My question is solved now.

TestUser
on 4/2/13, 9:00 AM

Sounds Good...:)

Francesco OpenCode
on 4/2/13, 11:13 AM

Where do you put this code?

Christophe
on 10/12/14, 9:08 PM
3

patrick

--patrick--
1958
| 5 4 7
Baarn, Netherlands
--patrick--
patrick
On 4/2/13, 8:45 AM

I do not know of a way of changing (and keeping) changes to screen fields, without modifying xml files.

It is possible to change the visibility of a field on the screen, you have to modify or create an XML-file. The advantage is also that this way you can reload the database without loosing your changes.

When a field is invisibile, it can store / keep values and/or the values will be stored in the database when saving the data. Sometimes a field is defined multiple times on a screen, so you hide one, and the other is still visible.

Example of hiding a field (in this case, hiding the taxes on sale.order.line):

  <xpath expr="//field[@name='order_line']/tree//field[@name='tax_id']" position="replace">
      <field name="tax_id" invisible="1"/>
  </xpath>

It is also possible to use attr{} so you can make it invisible depending on some things.

  <xpath expr="//field[@name='order_line']/tree//field[@name='tax_id']" position="replace">
      <field name="tax_id" attrs={'invisible':[('field name or property', '=', 'some vaue')]}/>
  </xpath>

Hope this helps you a little.

Thank you very much. Is it possible to hide the field depending on a user group?

TestUser
on 4/2/13, 8:49 AM

You can create a new group or use existing one and assign that group on the particular field like this: <field name="price" groups="NEW_GROUP_XML_ID"/>

Thanks, Priyesh Solanki

Priyesh Solanki (pso)
on 4/2/13, 9:10 AM
0
kitcle
On 9/6/14, 12:05 AM

try it.  Sure!

            <field name="arch" type="xml">    
                <xpath expr="//field[@name='order_line']/tree//field[@name='price_unit']" position="inside">
                    <field name="serial_no"/>
                </xpath>
            </field>

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: 4/2/13, 7:32 AM
Seen: 8061 times
Last updated: 8/29/15, 6:48 AM