Product Variant Default Code
This module automatically generate Product Reference (default_code) according to attributes data with a configurable behavior.
It defines a reference mask on the product templates so the variants references are automatically set. For example:
- Product template: Jacket
- Attributes:
- Color: White, Black
- Size: M, L
- Reference mask: JKT01-[Color]-[Size]
- Reference on variants:
- JKT01-Wh-M Jacket White M
- JKT01-Bl-M Jacket Black M
- JKT01-Wh-L Jacket White L
- JKT01-Bl-L Jacket Black L
auto_awesome What this module does
AI-generated from the code · Odoo 19.0Automatically builds the internal reference (default code) of product variants from their attributes, using a configurable mask such as [Color]-[Size].
This module lets you generate variant references automatically instead of typing them one by one. On a product template you get a 'Reference Prefix' and a 'Variant reference mask' (for example [Color]-[Size]), and each variant's internal reference is computed from the attribute codes.
- Attribute codes are added on product attributes and attribute values; if a value has no code, the first two characters of its name are used.
- A red warning appears on the product form when the reference cannot be computed, for example when the prefix or an attribute value code is missing.
- A 'Manual Reference' checkbox on the variant stops automatic recomputation, so you can keep a hand-written reference.
- In Settings, under Product Variants, you can switch between automatic mask and manual mask, and decide whether the template's reference prefix becomes the reference of single-variant products.
- The mask is checked on save: an unknown attribute name raises an error.
It touches product.template, product.product, product.attribute and product.attribute.value, and adds fields to the product, attribute and settings screens.
Depends on
Models and fields (5)
- product.product · extends an existing modelmanual_code (Manual Reference), default_code
- product.template · extends an existing modelcode_prefix (Reference Prefix), reference_mask (Variant reference mask), variant_default_code_error
- product.attribute · extends an existing modelcode (Attribute Code)
- res.config.settings · extends an existing modelprefix_as_default_code (Reference Prefix as default Reference), group_product_default_code_manual_mask (Product Default Code Manual Mask)
- product.attribute.value · extends an existing modelcode (Attribute Value Code)
Text generated by AI (DeepSeek) from reading the Odoo 19.0 code on GitHub; it may contain mistakes, so check the code before deciding. View the code on GitHub
Availability by version
Reviewed: 2026-11-03Confirmation status: 8 confirmed, 1 with no information of 9 versions.
Sources · Odoo 19.0
Confirmed on 2026-11-03 in branch 19.0 of OCA/product-variant.
terminal Installation and usage
OCA documentation · Odoo 19.0Usage
Source · Odoo 19.0To set the reference mask up on any product template 'Variant reference mask' new field.
When creating a new product template without specifying the Variant reference mask, a default value for Variant reference mask will be automatically generated according to the attribute line settings on the product template (if any). The mask will then be used as an instruction to generate default code of each product variant of the product template with the corresponding Attribute Code (of the attribute value) inserted. Besides the default value, Variant reference mask can be configured to your liking, make sure putting the Attribute Name inside [] marks (it is case sensitive).
Example:
Creating a product named Jacket with two attributes, Size and Color:
Product: Jacket Color: Black(Bl), White(Wh) # Black and White are the attribute values; 'Bl' and 'Wh' are the corresponding codes Size: L (L), XL(XL)
The automatically generated default value for the Variant reference mask will be [Color]-[Size] and so the 'default code' on the variants will be Bl-L, Wh-L, Bl-XL and Wh-XL.
The mask value can be fully customized whatever you like. You can even have the attribute name appear more than once in the mask such as, Jacket/[Size]~[Color]~[Size], and the generated code on variants will be something like Jacket/L~Bl~L (for variant with Color "Black" and Size "L").
When the code attribute is changed, it automatically regenerates the 'default code' on all variants affected.
Aditionally, a product attribute can be set and so it will be appended to the product default_code. In the first example, setting a Color code to CO would give default_code like this: COBl-L, COWh-L, COBl-XL and COWh-XL.
Avoiding mask in variants
You can avoid this behavior or force a manual default_code on variant. To do so, go to Product Variants \> [any variant you want to set up] and set manually its reference code. The field manual code will be set to on and the variant internal reference will no longer be changed by this module.
Unset manual code and the reference code will be unlocked again.
No verified information in OCA: Installation, Configuration.
Installation instructions, the distribution package, dependencies and configuration steps are not shown because they have not yet been verified in the module documentation for any version.
Data imported from GitHub: this sheet reflects the latest catalog review, not a live lookup. Always check the module documentation and staging before installing in production.