# Attribute Management

## Overview

Attributes define the variant axes of products. Each attribute is identified by a unique code and has a display name. Attributes hold a set of predefined values (e.g., "Red", "Blue" for a Color attribute). Products generate variants from the cartesian product of their assigned attribute values.

## Business Purpose

A flexible attribute system is essential for variant generation:

- **Variant axes** (e.g., Color, Size) determine the combinations that generate product variants. Each axis value maps to a distinct variant
- Attributes are always variant axes — there are no "descriptive-only" attributes in this module. Descriptive product information is handled via product fields or other modules

## Process Flow

```mermaid
flowchart TD
    A[Create Attribute] --> B[Add Attribute Values]
    B --> C[Assign to Product]
    C --> D[Generate Variants]
```

## Scenario Patterns

- **Color Attribute**: A "Color" attribute is created with values Red, Blue, Green. When assigned to a product, these values drive variant generation
- **Size Attribute**: A "Size" attribute is created with values S, M, L. Combined with Color, it produces the cartesian product (e.g., Red/S, Red/M, ..., Green/L)
- **Numeric Values as Select**: Values like "10mm", "12mm", "14mm" are modeled as select values, not as numeric types — they are discrete options for variant generation
- **Attribute Value Addition**: New values (e.g., "Yellow") are added to an existing attribute. Products using this attribute can then include the new value in variant generation
- **Attribute Name Update**: An attribute's display name can be updated at any time (e.g., renaming "Colour" to "Color"). The attribute's code remains unchanged
- **Attribute Value Label Update**: A value's display label can be updated at any time (e.g., fixing a typo, changing language). The value's identity (ID) is preserved, so existing variant references and generated SKUs are unaffected
- **Axis Structure Locked**: Once a product is ACTIVE, the set of attributes assigned to it is locked. New attributes cannot be assigned — only new values can be added to existing attributes. This prevents structure changes that would invalidate existing variants
- **Attribute Value Removal**: A value is removed from an attribute only if no ACTIVE product uses it as a variant value
- **Attribute Deletion**: An attribute can only be deleted if it is not assigned to any product

## Test Cases

- Attributes require a unique code and a display name
- Attribute code is immutable after creation
- Attribute value labels can be updated at any time without affecting variant structure or SKUs
- Attributes must have at least one value before being used for variant generation
- Attribute values must be unique within the attribute
- Attribute deletion is blocked if the attribute is assigned to any product
- Attribute value removal is blocked if the value is in use on any ACTIVE product

## Reference Links

- [Odoo Product Attributes](https://www.odoo.com/documentation/19.0/applications/sales/sales/products_prices/products/variants.html)
- [Akeneo Attribute Types](https://help.akeneo.com/pim/serenity/articles/what-about-products-variants.html)
