Duplicate SKU numbers in Odoo can create serious inventory and reporting issues.
By default, Odoo 19 Enterprise does not strictly prevent duplicate Internal Reference numbers (default code field). In growing organizations, this can lead to:
• Incorrect product dispatch
• Inventory mismatches
• Confusing sales reports
• Operational errors
In this video, I demonstrate how to prevent duplicate SKU creation in Odoo 19 using Automated Actions — without developing a custom module.
You will learn:
Why duplicate SKUs are risky in ERP systems
How Odoo handles Internal Reference by default
How to create an Automated Action in Odoo
Python code to block duplicate SKU
How to test and validate the solution
This is a practical Odoo implementation tip for consultants, ERP managers, and business owners.
If you found this helpful, like, comment, and subscribe for more Odoo implementation insights.
Custom Code:
Case-Sensitive Check
if record.default_code:
duplicate = env['product.template'].search([
('default_code', 'ilike', record.default_code),
('id', '!=', record.id)
])
for rec in duplicate:
if rec.default_code and rec.default_code.lower() == record.default_code.lower():
raise UserError("Internal Reference (SKU) already exists (case-insensitive match). Please use a unique SKU.")
Case-Insensitive Check
if record.default_code:
Search for products with same internal reference
duplicate = env['product.template'].search([
('default_code', '=', record.default_code),
('id', '!=', record.id)
], limit=1)
if duplicate:
raise UserError("Internal Reference (SKU) already exists for another product. Please use a unique SKU.")