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:
There are several options available to control the behaviour of the field:
- Read Only
All of these can be made “conditional” to give you more flexibility.
- 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!
Now we will make the field mandatory if it is a “storable” or “consumable” item.
Click on “Conditional” (next to “Required”):
Note the following:
- We select “ANY” (so either condition can be true).
- We select “Storable Product” and “Consumable”
- The domain is shown in the Code editor:
This is what happens if we forget to enter the Composition:
Reviewing fields added in Studio
If we enable “Developer” mode and go to Settings / 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:
- Product Template (product.template)
- 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 (but only after removing them from all views). You can also make some changes.