Backup your database
Always first! This is a destructive operation if done wrong.
Identify products to convert
Only proceed if the template has more than one variant.
templates_to_convert = env['product.template'].search([('product_variant_count', '>', 1)])
Iterate over each variant
Write a script to process each product.product variant and create a standalone product.template.
Example Logic (Python or Server Action):
for product in templates_to_convert.mapped('product_variant_ids'):
old_template = product.product_tmpl_id
# Copy fields from the template
new_template_vals = {
'name': f"{old_template.name} - {product.display_name}", # or custom naming
'type': old_template.type,
'categ_id': old_template.uom_po_id.id,
'taxes_id': [(6, 0, old_template.taxes_id.ids)],
'supplier_taxes_id': [(6, 0, old_template.supplier_taxes_id.ids)],
'description': product.description or old_template.description,
'default_code': product.default_code,
'barcode': product.barcode,
'image_1920': product.image_1920,
# add other fields you want to preserve
}
# Create new template
new_template = env['product.template'].create(new_template_vals)
# You can also update the product.product record if needed
new_product = new_template.product_variant_id
# Optional: Copy stock quantities, routes, BOMs, etc.
# Optional: deactivate old product or mark it for review
Copy extra info if needed
- Stock Quantities: Transfer from old variant to new product.
-
BOMs: Reassign to the new product.template.
-
Sales/Purchase history: Keep using the old product if traceability is important.
-
Custom Fields: If you've added custom fields, map them accordingly.