Product Class
by Camptocamp https://github.com/OCA/product-attribute , Odoo Community Association (OCA) https://github.com/OCA/product-attributeProduct Class

Product Class
This module introduces Product Classes for standardizing product setup and attribute management. It allows you to:
- Define Product Classes — Group related products into classes (e.g., “Furniture”, “Electronics”)
- Constrain Attributes per Class — Specify which attributes are allowed for each class
- Mark Required Attributes — Designate certain attributes as mandatory for products in that class
- 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
Table of contents
Usage
1. Create a Product Class
Navigation: Inventory → Configuration → Product Classes (or Sales → Configuration → Product Classes)
- Click Create button
- Enter a Product Class Name (e.g., “Chairs”)
- In the Attributes section:
- Click Add a line
- Select an Attribute from the dropdown
- Check Required if products of this class must define this attribute
- Repeat to add more attributes
- Click Save
Example: “Furniture” Class
| Attribute | Required | Notes |
|---|---|---|
| Color | ✓ | All furniture must have a color |
| Size | ✓ | Sizes vary by product |
| Material | Optional (not all items specify) | |
| Finish | Optional polish/coating |
2. Assign a Product to a Class
Navigation: Inventory → Products → Products
- Create or edit a product
- Find the Product Class field in the Attributes & Variants tab (added by this module)
- Select the class (e.g., “Furniture”)
- The form will now restrict Attributes to only those allowed by the class
3. Add Attribute Lines to a Classed Product
Once a class is selected, you can add attribute lines:
- Go to the Attributes & Variants tab
- In Attribute Lines, click Add a line
- The Attribute field dropdown is now filtered to show only class-allowed attributes
- Select an attribute and provide values
- Validation will fail if:
- You select an attribute not in the class → Error: “has attribute lines that do not belong”
- You leave out a required attribute → Error: “is missing required attributes”
4. Remove an Attribute from a Class
Scenario: Your “Furniture” class allowed “Color” but wants to retire it.
- Navigate to the class
- In Attributes, find the “Color” line and delete it
- Odoo will raise an error if products in this class still use
Color
- Fix: Remove Color from all products in the class first, then retry the class update
Workflow Example
Step 1: Set Up “Chairs” Class
- Color (required)
- Size (required)
- Leg Material (optional)
Step 2: Create a “Wooden Chair” Product
- Assign class: “Chairs”
- Add attribute “Color” = Red (satisfies required)
- Add attribute “Size” = Large (satisfies required)
- Add attribute “Leg Material” = Oak (optional, still valid)
- Save ✓ Success
Step 3: Try Invalid Assignment
- Assign class: “Chairs”
- Add attribute “Color” = Blue (satisfies required)
- Try to save without Size → Error: “is missing required attributes for the selected class ‘Chairs’: Size”
- Add Size = Medium
- Save ✓ Success
Class Attribute Line Model
The bridge model product.class.attribute.line stores:
| Field | Type | Purpose |
|---|---|---|
| class_id | Many2one | Product class (required, cascade delete) |
| attribute_id | Many2one | Product attribute (required) |
| required | Boolean | If true, products must define it |
Constraint: A class cannot configure the same attribute twice (unique on class_id + attribute_id).
Constraints & Validations
- Class Constraint (_check_attribute_ids_used_by_products)
- Prevents removing an attribute from a class if products still use it
- Error: “Cannot remove attributes used in products assigned to class…”
- Product Constraint (_check_class_attributes)
- Ensures all attribute lines belong to the class
- Ensures all required attributes are defined
- Error: “Product ‘…’ has attribute lines that do not belong to the selected class ‘…’”
- Error: “Product ‘…’ is missing required attributes for the selected class ‘…’”
Advanced: Access Control
- User (base.group_user): Can create/read/write product classes and their attributes
- System/Admin (base.group_system): Full CRUD including delete
Product class attribute lines follow the same access rules.
Bug Tracker
Bugs are tracked on GitHub Issues. In case of trouble, please check there if your issue has already been reported. If you spotted it first, help us to smash it by providing a detailed and welcomed feedback.
Do not contact contributors directly about support or help with technical issues.
Credits
Authors
- Camptocamp
Maintainers
This module is maintained by the OCA.
OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use.
Current maintainers:

This module is part of the OCA/product-attribute project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
Please log in to comment on this module