Skip to Content
Menu
This question has been flagged
3 Replies
2703 Views

Hello,

My products have multiple variants : size, location, color, ...

I need to remove all "size" variants from my products, but I always get an error in my automatic imports. I manage 20 000 products and cannot update it one by one.

Anyone would have an idea on what to do?


Best

Jeremy

Avatar
Discard
Best Answer

Hi Jeremy & Christophe

Totally get it — handling attributes like Size across 20,000 products in Odoo 14 can get tricky fast, especially with imports. The issue you’re facing is pretty common and usually tied to how Odoo 14 manages attribute lines and variant regeneration.

In Odoo 14, product variants are tightly linked to the attribute lines on the product template. If your import tries to remove an attribute (like “Size”) that’s actively generating variants, Odoo throws errors because it can’t reconcile the variant definitions.

Here’s how you can cleanly remove the “Size” attribute in bulk:

Step 1: Identify and unlink “Size” from attribute lines

Use the model product.template.attribute.line — export the records where attribute_id = Size.

In your export (via Excel or CSV):

  • Include fields: id, product_tmpl_id/id, attribute_id/id, value_ids/id

Then, either:

  • Manually delete those lines via the UI (tedious)
  • Or import a file with just the id column and leave all other fields empty to remove the line — or write a small script to unlink them.

Step 2: Remove obsolete variants

After removing the attribute lines, Odoo won’t automatically delete the existing product variants that had Size. You’ll need to remove them manually or through a script:

# WARNING: Use with caution. Only run after unlinking attribute lines.


size_attr = env['product.attribute'].search([('name', '=', 'Size')])

variant_ids = env['product.product'].search([

    ('product_template_attribute_value_ids.attribute_id', '=', size_attr.id)

])

variant_ids.unlink()

Make sure those variants aren't tied to existing sales ordes, stock moves or accounting records, otherwise odoo won't let you delete them.

Step 3: Rebuild your variants (optional)

If your products now only need Color or Location, you can go to each template and click “Update Variants” or trigger it via code. In Odoo 14, this sometimes has to be done template by template unless you automate it.

Tips for keeping it clean going forward

  • Disable the Size attribute (active = False) so it’s not reused in the future.
  • Add logic to your import scripts to exclude deprecated attributes.
  • If you’re doing catalog management at this scale regularly, consider a small module that gives you admin tools to clean attributes in bulk.

Let me know if you want help generating an import file or action script for this — no way you’re doing 20,000 one by one.

Avatar
Discard
Best Answer

Export those product template that contain size attribute then remember to choose external_id and product_variant_ids, attribute_line_ids and then it will give you a csv file
Then delete all data in column of variant and attribute
Then import back again in odoo done

Remember if some products exist in Sale Order or Pos Order you will need to handle them first

Avatar
Discard
Best Answer

I have the same question for weeks.. No one has an answer :(

Avatar
Discard

Export those product template that contain size attribute then remember to choose external_id and product_variant_ids, attribute_line_ids and then it will give you a csv file
Then delete all data in column of variant and attribute
Then import back again in odoo done

Remember if some products exist in Sale Order or Pos Order you will need to handle them first

Related Posts Replies Views Activity
2
Jun 25
449
4
Jan 18
8273
1
Feb 24
4891
0
Mar 23
1931
4
Mar 16
8542