Hi,
How could we import csv data into a many2one field with a related field linked to it in order to avoid having multiple matches for a given value?
An example will give a clearer view. I would like to import options in the product.variant.dimension.value object of the product_variant_multi module. I have several identical option names for different dimensions (88 option for length and width dimension for example). The two fields of the product.variant.dimension.value object are described below:
class product_variant_dimension_value(osv.Model):
_name = "product.variant.dimension.value"
def _get_values_from_options(self, cr, uid, ids, context=None):
return self.pool.get('product.variant.dimension.value').search(cr, uid, [('option_id', 'in', ids)], context=context)
_columns = {
'option_id' : fields.many2one('product.variant.dimension.option', 'Option', required=True, select = 2),
'dimension_id' : fields.related('option_id', 'dimension_id', type="many2one", relation="product.variant.dimension.type", string="Dimension Type", store={
'product.variant.dimension.value': (lambda self, cr, uid, ids, c={}: ids, ['option_id'], 10),
'product.variant.dimension.option': (_get_values_from_options, ['dimension_id'], 20),
}),}
class product_variant_dimension_option(osv.Model):
_name = "product.variant.dimension.option"
_columns = {
'name': fields.char('Dimension Option Name', size=64, required=True),
'code': fields.char('Code', size=64),
'sequence': fields.integer('Sequence'),
'dimension_id': fields.many2one('product.variant.dimension.type', 'Dimension Type', ondelete='cascade'),
}
How could we manage to import same name but different options within a certain domain defined by the dimension name?
Example of the csv rows I would like to import into product.template object:
name value_ids/dimension value_ids/option
Frame Width 88
Length 88
Any suggestions are welcome...