OdooWiki OCA HUB
Product License: AGPL-3

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

auto_awesome What this module does

AI-generated from the code · Odoo 19.0

Create product classes that group products and control which attributes they may use. Products assigned to a class can only use allowed attributes and must include the required ones.

This module adds a new concept called a Product Class, used to standardise how products are configured. A class is simply a named group (for example Furniture or Electronics) that lists the product attributes allowed for products in that group, and marks some of them as required.

Where it appears in Odoo: - A new Product Classes menu is available under Inventory > Products > Configuration and Sales > Products > Configuration. - On a product form, in the Variants tab, a new Product Class field appears above the attribute lines. - On an attribute form, a stat button shows how many product classes use that attribute and opens the list.

Business rules and automatic behaviour: - When you pick a class on a product, Odoo suggests the class required attributes as attribute lines (empty values), so you can fill them in. - The attribute selector on the product is limited to the attributes allowed by the chosen class. - Saving is blocked if the product uses an attribute that is not part of its class, or if a required attribute of the class is missing. - A class cannot be changed to remove an attribute that is still used by products assigned to it. - Class names must be unique, and each attribute can be listed only once per class. - Classes can be archived instead of deleted.

It touches product templates, product attributes and their attribute lines, and adds the new Product Class and Product Class Attribute Line records.

Depends on

productstocksale

Menus it adds

Product ClassesProduct Classes
Models and fields (4)
  • product.class · new modelname, active, attribute_line_ids (Attributes)
  • product.template · extends an existing modelclass_id (Product Class), class_attribute_ids (Class Attributes), class_required_attribute_ids (Class Required Attributes)
  • product.attribute · extends an existing modelclasses_count (Product Classes Count), class_attribute_line_ids (Class Attribute Lines)
  • product.class.attribute.line · new modelclass_id (Product Class), required, attribute_id

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-03
Confirmed (verified in repository and branch) Estimated (unverified) No information

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

Sources · Odoo 19.0

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

terminal Installation and usage

OCA documentation · Odoo 19.0

Usage

  • 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 |

  • 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
  • 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"
  • 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.

No verified information in OCA: Installation, Configuration.

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.