OdooWiki OCA HUB

Create product variant from custom value

product_attribute_custom_value_variant folder_open OCA/product-attribute open_in_new
Sales/Sales License: AGPL-3

Create variants when configured custom attributes are used.

The created variants are useful to retrieve the stock quantity or for purchase.

auto_awesome What this module does

AI-generated from the code · Odoo 16.0

When a customer enters a custom value for a product attribute on a sales order, Odoo automatically creates a real product variant for that value instead of just storing the text. This makes the custom variant usable for stock, purchasing and reporting.

This module changes how custom attribute values behave on sales orders. Normally, when a customer types a free-text value for an attribute (for example a custom engraving), Odoo keeps it only as text on the order line. With this module, if the attribute value is flagged as "Create custom variant", Odoo creates a real product variant for that custom text and assigns it to the order line.

Where it appears: - On the product attribute form, the list of attribute values now has a hidden-by-default column "Create custom variant" (visible only to users with the product variant group). - The flag can only be set on values that are already marked as custom; otherwise Odoo raises a validation error.

What happens automatically: - When a sales order line is created with a custom attribute value whose attribute value has the flag enabled, Odoo looks up or creates a matching attribute value, adds it to the product's attribute line, builds the correct variant combination and replaces the order line's product with the new variant. - The temporary custom value record on the line is then removed. - When variants are cleaned up, variants that were just created for custom values are protected from being deleted or archived.

It touches product attributes, attribute values, product variants and sales order lines.

Depends on

productsale
Models and fields (3)
  • sale.order.line · extends an existing model
  • product.attribute · extends an existing model
  • product.attribute.value · extends an existing modelcreate_custom_variant (Create custom variant)

Text generated by AI (DeepSeek) from reading the Odoo 16.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-03
Confirmed (verified in repository and branch) Estimated (unverified) No information

Confirmation status: 1 confirmed, 8 with no information of 9 versions.

Sources · Odoo 16.0

Confirmed on 2026-11-03 in branch 16.0 of OCA/product-attribute.

terminal Installation and usage

OCA documentation · Odoo 16.0

In any custom attribute value, enable Create custom variant.

When a product template is added to a sale order line, the configured custom values become real attribute values. Here is an example:

  • Create an attribute "Length (cm)"
  • Add some values to the attribute:
  • 5
  • 10
  • Custom
  • For the "Custom" value, enable custom and Create custom variant (added by this module)
  • Create a product template "Glass" having the created attribute and all its values
  • Create a sale order that includes the product template
  • Set the value 42 for the attribute "Length (cm)"

With the above steps, this module creates:

  • | A new attribute value "42" for the attribute "Length (cm)" | This attribute value is not linked to the product template, so it does not appear as a choice when the template is sold.
  • A variant for the template, linked to the created attribute value

The created variant can then be used to retrieve its stock quantity or to purchase that exact product variant that had been sold.

No verified information in OCA: Installation.

info

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.