- Move origin_text field from product.supplierinfo to product.template - Add related field in product.product for variant access - Remove dependency on product_main_seller - Update views to show field near category (editable) - Rewrite tests for new architecture - Update all documentation (README, readme/ fragments) - Bump version to 18.0.2.0.0
2.8 KiB
2.8 KiB
Product Origin Text - Developer Notes
Technical Implementation
Architecture
This module adds a simple free-text origin field to products.
Models:
-
product.template - Base model with the
origin_textfield- Field:
origin_text(Char) - This is where the actual data is stored
- Editable directly on the product form
- Field:
-
product.product - Related field for variant access
- Field:
origin_text(Char, related toproduct_tmpl_id.origin_text) readonly=Falseallows editing from variant views- Changes propagate to the template
- Field:
Why This Architecture?
The origin_text field is stored in product.template because:
- Origin typically applies to all variants of a product
- Simplifies data management (one source of truth)
- Avoids duplication across variants
- Standard Odoo pattern for product-level attributes
The related field in product.product with readonly=False allows:
- Seamless access from variant views
- Editing from either template or variant forms
- Automatic synchronization between template and variants
Previous Architecture (Deprecated)
The previous version stored origin_text in product.supplierinfo with computed
fields in template/product. This was deprecated because:
- Supplierinfo records don't always exist when products are created
- Added unnecessary complexity with computed fields
- Required
product_main_sellerdependency - Origin semantically belongs to the product, not the supplier relationship
Dependencies
- product - Core product module (only dependency)
Performance Considerations
- Simple stored field with no computation overhead
- Related field access is efficient in Odoo ORM
- No additional queries needed for variant access
Testing Strategy
Tests cover:
- Basic field storage - Set origin on template
- Related field access - Verify variant sees template origin
- Write from variant - Verify changes propagate to template
- Empty cases - Products without origin
- Multiple products - Independent origins
- Variants - All variants share same origin
Code Quality
- Follows OCA guidelines
- Black formatted (line length 88)
- isort for imports
- Minimal dependencies (only
product)
Migration from v1.x
If upgrading from the previous supplier-based architecture:
- Data in
product.supplierinfo.origin_textwill need manual migration - Run migration script to copy main supplier origin to product template
- Remove dependency on
product_main_sellerif no longer needed
Version History
-
18.0.2.0.0 (2026-03-06) - Simplified architecture
- Field directly on product.template
- Related field in product.product
- Removed dependency on product_main_seller
-
18.0.1.0.0 (2026-02-25) - Initial release (deprecated)
- Free-text origin field per supplier
- Automatic display based on main vendor