This question has been flagged
3 Replies
16864 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...?

Avatar
Discard
Best Answer

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>
Avatar
Discard
Author

Thank you too. My question is solved now.

Sounds Good...:)

Where do you put this code?

Best Answer

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.

Avatar
Discard
Author

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

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

Best Answer

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>

Avatar
Discard