Repository
OCA/product-attribute · module folder · Try on Runboat
Module version
Category
Product
Folder size
0.09 MB
License
AGPL-3
Application
No
Auto-installable
No
Website
https://github.com/OCA/product-attribute
Last tracking update
2026-08-10 17:31:07
Authors
Camptocamp, Odoo Community Association (OCA)
Maintainers
Camptocamp, Odoo Community Association (OCA)
Committers
Ricardoalso, Iván Todorovich, Weblate, OCA-git-bot, oca-ci
Odoo dependencies
Python dependencies
None
System dependencies
None
Required by
None
Description
## Product Class

This module introduces **Product Classes** for standardizing product setup and attribute management. It allows you to:

1. **Define Product Classes** — Group related products into classes (e.g., "Furniture", "Electronics")
2. **Constrain Attributes per Class** — Specify which attributes are allowed for each class
3. **Mark Required Attributes** — Designate certain attributes as mandatory for products in that class
4. **Enforce Validation** — Prevent products from using attributes outside their class or missing required attributes

### Key Features

- **Bridge Model (`product.class.attribute.line`)** — Manages the relationship between classes and attributes, storing both allowed attributes and a `required` flag
- **Strict Validation** — Products assigned to a class must:
  - Use only attributes defined in that class
  - Provide values for all required attributes
- **UI Enforcement** — Attribute selection in product forms is restricted by the class domain filter
- **Management Views** — Full CRUD interface for product classes (Inventory > Configuration > Product Classes, Sales > Configuration > Product Classes)

### Technical Architecture

- `product.class` — Main product classification model
- `product.class.attribute.line` — Bridge model linking classes to attributes with a `required` flag
- `product.attribute` (inherited) — Extended with reverse one-to-many to track which classes use it
- `product.template` (inherited) — Added class validation and computed required-attribute tracking

Code Analysis

Views touched (5)
XML IDNameModelTypeStatus
product_attribute_view_form product.attribute form Inherits product.product_attribute_view_form
product_class_form product.class form New
product_class_list product.class list New
product_class_search product.class search New
product_template_form_view product.template form Inherits product.product_template_only_form_view
HTTP endpoints (0)

No HTTP endpoints found for this module.

Models touched (4)

New fields (2)
  • class_attribute_line_ids One2many → product.class.attribute.line
    comodel_name='product.class.attribute.line' help='Product classes that include this attribute.' inverse_name='attribute_id' string='Class Attribute Lines'
  • classes_count Integer
    compute='_compute_classes_count' string='Product Classes Count'
Public methods (1)
  • action_open_product_classes(self)

New fields (3)
  • active Boolean
    default=True
  • attribute_line_ids One2many → product.class.attribute.line
    comodel_name='product.class.attribute.line' help='Allowed attributes for products of thisclass and whether they are required.' inverse_name='class_id' string='Attributes'
  • name Char
    translate=True
Public methods (0)

No public methods.

New fields (3)
  • attribute_id Many2one → product.attribute
    comodel_name='product.attribute' index=True ondelete='restrict' required=True string='Attribute'
  • class_id Many2one → product.class
    comodel_name='product.class' index=True ondelete='cascade' required=True string='Product Class'
  • required Boolean
    default=False help='If enabled, products of this class must define this attribute.'
Public methods (0)

No public methods.

New fields (3)
  • class_attribute_ids Many2many → product.attribute
    comodel_name='product.attribute' compute='_compute_class_attribute_ids' help='Attributes allowed by the selected product class' string='Class Attributes'
  • class_id Many2one → product.class
    comodel_name='product.class' help='Product class that constrains which attributes can be used' string='Product Class'
  • class_required_attribute_ids Many2many → product.attribute
    comodel_name='product.attribute' compute='_compute_class_attribute_ids' help='Required attributes for the selected product class.' string='Class Required Attributes'
Public methods (0)

No public methods.