Making a field invisible

Here’s a simple example of using an Extension View to make a field invisible. The field is the Invoice Date on the Customer Invoice or Supplier Invoice (Vendor Bill).

Odoo 13 CE

Enable developer mode and navigate to Settings / Technical / Views.

Create a new view

View Name: Hide invoice date
View Type: Form
Model: account.move
Inherited View: account.move.form
View inheritance mode: Extension View

To find the Inherited View it’s advisable to enter some search criteria:

Architecture

<data>
   <xpath expr="//field[@name='invoice_date']" position="attributes">
     <attribute name="groups">account.group_account_manager</attribute>
   </xpath>
</data>

Note: the Invoicing / Accounting app in Odoo 13 CE has two roles:

  1. Billing [account.group_account_invoice]
  2. Billing Manager [account.group_account_manager]

The “Billing” role is the more junior, and so we will only allow the Manager to view the invoice date.

There is a small problem with this. Hiding the field doesn’t hide the label:

That’s because the label depends upon the type of invoice, but that’s a problem for another day!

Odoo 13 Enterprise Edition

The database structure is the same, but the user access groups are different:

  1. Billing [account.group_account_invoice]
  2. Accountant [account.group_account_user]
  3. Advisor [account.group_account_manager]

This requires a small change to the XML (assuming that we want the Accountant to be able to edit invoice dates)

<data>
   <xpath expr="//field[@name='invoice_date']" position="attributes">
     <attribute name="groups">account.group_account_user</attribute>
   </xpath>
</data>

Odoo Studio

It’s also possible to make this change by using Odoo Studio

Enable Odoo Studio and click on the Invoice Date field

This will create an Extension View

Odoo 12 EE

The Model and Field names are different (there was a big change in Odoo 13), but the user access groups are the same.

This is the Extension View

Architecture

<data>
  <xpath expr="//field[@name='date_invoice']" position="attributes">
    <attribute name="groups">account.group_account_user</attribute>
  </xpath>
</data>

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s