parameters: (self, combination, log_warning=False)
return_statement: return Product.sudo().create({
              'product_tmpl_id': self.id,
              'product_template_attribute_value_ids': [(6, 0, combination._without_no_variant_attributes().ids)]
          })
docstring: Create if necessary and possible and return the product variant
          matching the given combination for this template.
  
          It is possible to create only if the template has dynamic attributes
          and the combination itself is possible.
          If we are in this case and the variant already exists but it is
          archived, it is activated instead of being created again.
  
          :param combination: the combination for which to get or create variant.
              The combination must contain all necessary attributes, including
              those of type no_variant. Indeed even though those attributes won't
              be included in the variant if newly created, they are needed when
              checking if the combination is possible.
          :type combination: recordset of `product.template.attribute.value`
  
          :param log_warning: whether a warning should be logged on fail
          :type log_warning: bool
  
          :return: the product variant matching the combination or none
          :rtype: recordset of `product.product`
docstring_summary: Create if necessary and possible and return the product variant
          matching the given combination for this template.
docstring_tokens: Create if necessary and possible and return the product variant matching the given combination for this template .
function: def _create_product_variant(self, combination, log_warning=False):
          """ Create if necessary and possible and return the product variant
          matching the given combination for this template.
  
          It is possible to create only if the template has dynamic attributes
          and the combination itself is possible.
          If we are in this case and the variant already exists but it is
          archived, it is activated instead of being created again.
  
          :param combination: the combination for which to get or create variant.
              The combination must contain all necessary attributes, including
              those of type no_variant. Indeed even though those attributes won't
              be included in the variant if newly created, they are needed when
              checking if the combination is possible.
          :type combination: recordset of `product.template.attribute.value`
  
          :param log_warning: whether a warning should be logged on fail
          :type log_warning: bool
  
          :return: the product variant matching the combination or none
          :rtype: recordset of `product.product`
          """
          self.ensure_one()
  
          Product = self.env['product.product']
  
          product_variant = self._get_variant_for_combination(combination)
          if product_variant:
              if not product_variant.active and self.has_dynamic_attributes() and self._is_combination_possible(combination):
                  product_variant.active = True
              return product_variant
  
          if not self.has_dynamic_attributes():
              if log_warning:
                  _logger.warning('The user #%s tried to create a variant for the non-dynamic product %s.' % (self.env.user.id, self.id))
              return Product
  
          if not self._is_combination_possible(combination):
              if log_warning:
                  _logger.warning('The user #%s tried to create an invalid variant for the product %s.' % (self.env.user.id, self.id))
              return Product
  
          return Product.sudo().create({
              'product_tmpl_id': self.id,
              'product_template_attribute_value_ids': [(6, 0, combination._without_no_variant_attributes().ids)]
          })
function_tokens: def _create_product_variant ( self , combination , log_warning = False ) : self . ensure_one ( ) Product = self . env [ 'product.product' ] product_variant = self . _get_variant_for_combination ( combination ) if product_variant : if not product_variant . active and self . has_dynamic_attributes ( ) and self . _is_combination_possible ( combination ) : product_variant . active = True return product_variant if not self . has_dynamic_attributes ( ) : if log_warning : _logger . warning ( 'The user #%s tried to create a variant for the non-dynamic product %s.' % ( self . env . user . id , self . id ) ) return Product if not self . _is_combination_possible ( combination ) : if log_warning : _logger . warning ( 'The user #%s tried to create an invalid variant for the product %s.' % ( self . env . user . id , self . id ) ) return Product return Product . sudo ( ) . create ( { 'product_tmpl_id' : self . id , 'product_template_attribute_value_ids' : [ ( 6 , 0 , combination . _without_no_variant_attributes ( ) . ids ) ] } )