Repository
OCA/product-variant · module folder · Try on Runboat
Module version
Category
Product Variant
Folder size
1.87 MB
License
AGPL-3
Application
No
Auto-installable
No
Website
https://github.com/OCA/product-variant
Last tracking update
2026-08-21 11:28:21
Authors
ACSONE SA/NV, Odoo Community Association (OCA), AvanzOSC, Tecnativa
Maintainers
ACSONE SA/NV, Odoo Community Association (OCA), AvanzOSC, Tecnativa
Committers
Weblate, OCA-git-bot, oca-ci, Andrii9090-tecnativa, arantxa-s73
Odoo dependencies
odoo/odoo:
- web
- bus
- uom
Python dependencies
None
System dependencies
None
Required by
purchase_variant_configurator, sale_variant_configurator
Description
Provides an abstract model for product variant configuration. It
provides the basic functionality for presenting a table with the
attributes of a template and the possibility to select one of the valid
values. You can try this functionality creating a product variant
directly selecting a product template that has attributes.

This module also prevents in a configurable way the creation of the
product variants when defining the attributes and attribute values of
the product template.

Code Analysis

Views touched (6)
XML IDNameModelTypeStatus
product_attribute_view_form product.attribute.form product.attribute form Inherits product.product_attribute_view_form
product_category_no_variant_form_view product.category.no.variant.form product.category form Inherits product.product_category_form_view
product_template_no_variant_form_view product.template.no.variant.form product.template form Inherits product.product_template_only_form_view
product_variants_view product.product.variants.form product.product form Inherits product.product_normal_form_view
product_variants_view_2 product.product.variants.form product.product form Inherits product_variant_configurator.product_variants_view
view_product_configurator_tree product.configurator.attribute list New
HTTP endpoints (0)

No HTTP endpoints found for this module.

Models touched (9)

New fields (0)

No new fields.

Public methods (0)

No public methods.

New fields (0)

No new fields.

Public methods (1)
  • create(self, vals_list)
    @api.model_create_multi
    Link created attribute value to the associated template if proceed. This happens when quick-creating values from the product configurator.

New fields (1)
  • no_create_variants Boolean
    default=True help='This check disables the automatic creation of product variants for all the products of this category.' string="Don't create variants automatically"
Public methods (2)
  • onchange_no_create_variants(self)
    @api.onchange('no_create_variants')
  • write(self, values)

New fields (7)
  • can_create_product Boolean
    compute='_compute_can_be_created'
  • create_product_variant Boolean
    string='Create product now!'
  • price_extra Float
    compute='_compute_price_extra' digits='Product Price' help='Price Extra: Extra price for the variant with the currently selected attributes values on sale price. eg. 200 price extra, 1000 + 200 = 1200.'
  • product_attribute_ids One2many → product.configurator.attribute
    comodel_name='product.configurator.attribute' copy=True domain=<expr> inverse_name='owner_id' string='Product attributes'
  • product_id Many2one → product.product
    comodel_name='product.product' string='Product Variant'
  • product_id_configurator_domain Binary
    compute='_compute_product_id_configurator_domain' readonly=True store=False
  • product_tmpl_id Many2one → product.template
    bypass_search_access=True comodel_name='product.template' string='Product Template'
Public methods (3)
  • create(self, vals_list)
    @api.model_create_multi
    Fill `product_tmpl_id` in case `product_id` is supplied but not the other one.
  • create_variant_if_needed(self)
    Create the product variant if needed. It searches for an existing product with the selected attributes. If not found, create a new product. :returns: the product (found or newly created)
  • unlink(self)
    Mimic `ondelete="cascade"`.

New fields (7)
  • attribute_id Many2one → product.attribute
    comodel_name='product.attribute' readonly=True string='Attribute'
  • owner_id Many2oneReference
    index=True model_field='owner_model' required=True string='Owner'
  • owner_model Char
    required=True
  • possible_value_ids Many2many → product.attribute.value
    comodel_name='product.attribute.value' compute='_compute_possible_value_ids' readonly=True
  • price_extra Float
    compute='_compute_price_extra' digits='Product Price' help='Price Extra: Extra price for the variant with this attribute value on sale price. eg. 200 price extra, 1000 + 200 = 1200.' string='Attribute Price Extra'
  • product_tmpl_id Many2one → product.template
    comodel_name='product.template' required=True string='Product Template'
  • value_id Many2one → product.attribute.value
    comodel_name='product.attribute.value' domain="[('id', 'in', possible_value_ids)]" string='Value'
Public methods (0)

No public methods.

New fields (0)

No new fields.

Public methods (2)
  • template_price_get(self, prod_id, qty, partner=None)
  • template_price_rule_get(self, prod_id, qty, partner=None)

New fields (0)

No new fields.

Public methods (1)
  • create(self, vals_list)
    @api.model_create_multi

New fields (1)
  • no_create_variants Selection
    default='no' help='This selection defines if variants for all attribute combinations are going to be created automatically at saving time.' required=True string='Variant creation' args: [('yes', "Don't create them automatically"), ('no', "Use Odoo's default variant management"), ('empty', 'Use the category value')]
Public methods (4)
  • create(self, vals_list)
    @api.model_create_multi
  • name_search(self, name='', domain=None, operator='ilike', limit=100)
    @api.model
  • onchange_no_create_variants(self)
    @api.onchange('no_create_variants')
  • write(self, values)

New fields (1)
  • required Boolean
    default=False
Public methods (0)

No public methods.

Loading…

Loading…

Loading…

Loading…

Loading…

Loading…

Loading…

Loading…

Loading…

Loading…