How to Extend Product Template Fields in Odoo 19
#Odoo Product Template #Odoo Custom Fields #Odoo Module Development #MLM in Odoo #Odoo Backend

How to Extend Product Template Fields in Odoo 19

Odoo is designed with extensibility at its core. One of the most common customization requirements is to extend existing models without modifying the core code. In this article, we will learn how to extend Product Template fields in Odoo 19 by adding a custom MLM (Multi-Level Marketing) column to products using proper model and view inheritance.

This approach follows Odoo best practices and ensures future upgrades remain safe and maintainable.

Why Extend product.template Instead of Core Modification?

In Odoo, products are managed mainly through the product.template model. Extending this model allows us to:

  • Add custom business logic (MLM, commissions, subscriptions, etc.)
  • Control product behavior without touching core files
  • Maintain upgrade compatibility
  • Reuse the field across Sales, Inventory, Accounting, and Reports

For MLM systems, it is essential to identify which products participate in MLM commissions. This can be done cleanly by adding a Boolean field to the product template.

Business Requirement

We want to add:

  • A custom field “MLM Product”
  • Stored at product level
  • Visible in the Product form view
  • Usable in MLM commission logic later

Technical Overview

We will:

  • Extend the product.template model
  • Add a Boolean column for MLM
  • Inherit the Product Form View
  • Display the field in the Sales tab

Step 1: Create or Use a Custom Module

Assuming you already have an MLM module (example: letscms_unilevel).

If not, always create a custom module instead of modifying core addons.

Step 2: Extend Product Template Model

File: models/product_template.py

from odoo import models, fields
class ProductTemplate(models.Model):
    _inherit = 'product.template'
    is_mlm_product = fields.Boolean(
        string="MLM Product",
        help="Enable this option if the product participates in MLM commissions"
    )

Why this works

  • _inherit safely extends the existing model
  • Boolean fields are lightweight and efficient
  • The field is automatically stored in the database

Register the Model

File: models/__init__.py

from . import letscms_product_template

Step 3: Extend Product Form View

Now we need to expose the field in the UI.

File: views/admin/settings/letscms_product_template_views.xml

    
        product.template.form.mlm
        product.template
        
        
            
            
                
            
        
    

Why place it in the Sales tab?

  • MLM logic is usually tied to sales orders
  • Keeps product configuration organized
  • Matches Odoo UI standards

Step 4: Load the View in Manifest

File: __manifest__.py

# -*- coding: utf-8 -*-
{
    'name': 'LetsCMS Unilevel',
    'version': '19.0.1.0.0',
    'category': 'Sales/CRM',
    'summary': 'Unilevel MLM Network Marketing System',
    'description': """
        Unilevel MLM Network Marketing System
        =====================================
        * Manage MLM members and network structure
        * Unilevel compensation plan
        * Commission calculations
        * Genealogy tree view
        * Member registration and management
    """,
    'author': 'LetsCMS',
    'website': 'https://www.letscms.com',
    'license': 'LGPL-3',
    'depends': [
        'base',
        'sale_management',
        'contacts',
        'product',
    ],
    'data': [
        'security/ir.model.access.csv',
        'views/admin/settings/letscms_general_settings_views.xml',
        'views/admin/actions/letscms_general_settings.xml',
        'views/admin/settings/letscms_eligibility_settings_views.xml',
        'views/admin/actions/letscms_eligibility_settings.xml',
        'views/admin/settings/letscms_commission_level_views.xml',
        'views/admin/actions/letscms_level_settings.xml',
        'views/admin/settings/letscms_product_template_views.xml',
        'views/admin/letscms_unilevel_menu.xml',
    ],
    'demo': [],
    'images': ['static/description/banner.png'],
    'installable': True,
    'application': True,
    'auto_install': False,
}

Step 5: Upgrade the Module

Upgrade your module to apply changes:

   ./odoo-bin -c mini1_odoo19unilevel.conf -d odoo19unilevel

Or via:

Apps > Update Apps List > Upgrade LetsCMS Unilevel

Final Result

After upgrading:

  • Go to Sales → Products
  • Open any product
  • Navigate to Sales tab
  • You will see a new option:

MLM Product Field in Odoo 19 Product Form View

This field is now available throughout the system.

Using the MLM Field in Business Logic

Later, this field can be used to control commission logic:

    if order_line.product_id.is_mlm_product:
        # Apply MLM commission

This ensures only eligible products generate MLM earnings.

Optional Enhancements

Add Filter in Product List View

    

Restrict MLM for Services or Digital Products

@api.constrains('is_mlm_product', 'type')
def _check_mlm_product_type(self):
    for product in self:
        if product.is_mlm_product and product.type == 'service':
            raise ValidationError("MLM is not allowed for service products.")

Best Practices for Odoo Product Extensions

  • Always extend product.template
  • Use _inherit, never override core models
  • Keep UI changes minimal and logical
  • Store business flags as Boolean fields
  • Drive workflows via server-side logic

Conclusion

Extending Product Template fields in Odoo 19 is a clean and scalable way to implement custom business requirements like MLM systems. By using model inheritance and view extension, we can add powerful functionality while staying fully aligned with Odoo’s architecture.

This approach ensures:

  • Upgrade safety
  • Clean codebase
  • Reusable business logic
×
MLM PLAN
×
×