title: How to create product variants from the product template attribute lines in Odoo?
body: <p>I am using Odoo 10 and I have created a group of product templates. As I have product variants enabled, each product template has generated a product variant. Then, I have imported a CSV file which adds product attribute lines to the product templates. It worked well as product templates have now their respective attribute lines.</p>
  
  <p>Since I have imported these attribute lines instead of creating them by hand, they generated no product variant. For example, I have imported the attribute line <em>Size</em> with <em>S</em>, <em>M</em>, <em>L</em> values for the template <em>T-shirt</em>. I expected Odoo to remove the single <em>T-Shirt</em> variant and generate the variants <em>T-shirt S</em>, <em>T-shirt M</em> and <em>T-shirt L</em> (which is the behaviour when you add an attribute or an attribute value to the template), but it did nothing.</p>
  
  <p>So I am trying to generate them through code, I am using the shell for that. First I search for the templates I have created. Once I have them stored in a variable named <code>templates</code>, I execute the <code>create_variant_ids</code> to the templates recordset:</p>
  
  <pre><code>&gt;&gt;&gt; templates = self.env['product.template'].search([('create_date', '&gt;=', '2019-01-06 00:00:00')])
  &gt;&gt;&gt; templates.create_variant_ids()
  </code></pre>
  
  <p>The result is this one:</p>
  
  <pre><code>2019-01-09 10:33:00,993 2775 INFO trivi_v10 odoo.models.unlink: User #1 deleted product.product records with IDs: [1052]
  2019-01-09 10:33:01,782 2775 INFO trivi_v10 odoo.models.unlink: User #1 deleted product.product records with IDs: [1061]
  2019-01-09 10:33:02,573 2775 INFO trivi_v10 odoo.models.unlink: User #1 deleted product.product records with IDs: [1054]
  2019-01-09 10:33:03,353 2775 INFO trivi_v10 odoo.models.unlink: User #1 deleted product.product records with IDs: [1055]
  2019-01-09 10:33:04,166 2775 INFO trivi_v10 odoo.models.unlink: User #1 deleted product.product records with IDs: [1056]
  2019-01-09 10:33:05,000 2775 INFO trivi_v10 odoo.models.unlink: User #1 deleted product.product records with IDs: [1057]
  2019-01-09 10:33:05,828 2775 INFO trivi_v10 odoo.models.unlink: User #1 deleted product.product records with IDs: [1058]
  2019-01-09 10:33:06,621 2775 INFO trivi_v10 odoo.models.unlink: User #1 deleted product.product records with IDs: [1053]
  2019-01-09 10:33:07,438 2775 INFO trivi_v10 odoo.models.unlink: User #1 deleted product.product records with IDs: [1059]
  2019-01-09 10:33:08,241 2775 INFO trivi_v10 odoo.models.unlink: User #1 deleted product.product records with IDs: [1060]
  2019-01-09 10:33:09,051 2775 INFO trivi_v10 odoo.models.unlink: User #1 deleted product.product records with IDs: [1051]
  2019-01-09 10:33:09,841 2775 INFO trivi_v10 odoo.models.unlink: User #1 deleted product.product records with IDs: [956]
  Traceback (most recent call last):
    File "&lt;console&gt;", line 1, in &lt;module&gt;
    File "/opt/odoo/odoo_10/src/linked/product/models/product_template.py", line 403, in create_variant_ids
      'attribute_value_ids': [(6, 0, variant_ids.ids)]
    File "/opt/odoo/odoo_10/src/linked/product/models/product.py", line 322, in create
      product = super(ProductProduct, self.with_context(create_product_product=True)).create(vals)
    File "/opt/odoo/odoo_10/src/linked/mail/models/mail_thread.py", line 228, in create
      thread = super(MailThread, self).create(values)
    File "/opt/odoo/odoo_10/src/oca/OCB/odoo/models.py", line 3847, in create
      record = self.browse(self._create(old_vals))
    File "/opt/odoo/odoo_10/src/oca/OCB/odoo/models.py", line 4002, in _create
      self._validate_fields(vals)
    File "/opt/odoo/odoo_10/src/oca/OCB/odoo/models.py", line 1078, in _validate_fields
      check(self)
    File "/opt/odoo/odoo_10/src/linked/product/models/product.py", line 310, in _check_attribute_value_ids
      raise ValidationError(_('Error! It is not allowed to choose more than one value for a given attribute.'))
  ValidationError: (u'Error! It is not allowed to choose more than one value for a given attribute.', None)
  </code></pre>
  
  <p>I thought that product variant with ID 956 will have something wrong, but it has similar data to the rest of variants.</p>
  
  <p>Does anyone know how to create the product variants (through code or interface)?</p>