Adding fields using Odoo Studio

We can use Odoo Studio to add many different field types, and the process is basically the same for all of them. However, the database fields are more complex, and there is more information here

Character (text) fields

Let’s add a text field to store the composition of a garment.

First step is enable Odoo Studio

Then we will drag a new text field on to the Form View for products:

You can drag it wherever you want on the current tab (and in Odoo 12 and later versions you can move it if you put it in the wrong place).

Note that the added field (initially) has a meaningless name

So the next thing to do is give the new field a meaningful name:

Notice that this will update the field name (“Technical Description”) and the “label”, which is the description shown on screen.

If you don’t change the name now, you will NOT be able to do it later (though you can change the “label” that is shown on the screen).

So now we have the new field available for use:

More options

There are several options available to control the behaviour of the field:

  • Invisible
  • Required
  • Read Only

All of these can be made “conditional” to give you more flexibility.

Making a field invisible

  • For example, you might want to make this field invisible if this is a “service” item – and mandatory (required) if not.

Click on “Conditional” next to “Invisible” and the following window is displayed:

Click on “Add Filter” and then select “Product Type”

There are three possible values for “Product Type”, and we will make the field invisible if it’s a Service Item:

Note that the domain is shown in the “code editor” section. You can edit this if you wish!

Making a field mandatory (required)

Now we will make the field mandatory if it is a “storable” or “consumable” item.

Click on “Conditional” (next to “Required”):

Note the following:

  1. We select “ANY” (so either condition can be true).
  2. We select “Storable Product” and “Consumable”
  3. The domain is shown in the Code editor:
["|",["type","=","product"],["type","=","consu"]]

This is what now happens if we forget to enter the Composition:

Reviewing fields added in Studio

If we enable “Developer” mode and go to Settings / Technical / Fields we can check what has been added.

We can see that two fields have been created by Studio:

This is a special case. Odoo has two closely linked tables for:

  1. Product Template (product.template)
  2. Product (product.product)

If you don’t use variants, then these two tables will be the same.

If you do use variants, then the “parent” item is on product.template and the SKUs are on product.product

You can delete fields here if you added them by mistake:

Remember to remove them from all views first before deleting them (Odoo won’t allow you to delete them if they are used anywhere).

  • Tip: you can search through the architecture of all views to find where a field is used.

You can also make some changes to field attributes.

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