Hi,
I've developed a module that set the 'default_code' from product as unique and required.
Like this:
class product_product(osv.osv):
_inherit = "product.product"
_columns = {
#'default_code' : fields.char('Reference', size=30, required=True),
'default_code' : fields.char('Internal Reference', size=30, select=True, required = True),
}
_sql_constraints = [('code_unique','unique(default_code)', _("Product code must be unique!")),
]
product_product()
Now I try to install 'product_variant_multi' in a BD with my new module, and I'm facing some problems with the condition that I've give to 'default_code'. I've the problem with the required setting that Igive to the field, I fixed this by inherit the function 'button_generate_variants ' and change this:
for variant in list_of_variants_to_create:
vi_code = product_temp.name +'_'+str(count)
print vi_code
count += 1
vals = {
'name': product_temp.name,
'track_production': product_temp.variant_track_production,
'track_incoming': product_temp.variant_track_incoming,
'track_outgoing': product_temp.variant_track_outgoing,
'product_tmpl_id': product_temp.id,
'dimension_value_ids': [(6, 0, variant)],
'default_code': vi_code,
}
So I need to change the code generator in the form of product templates (the red area in the picture):

So I want to change this: [_'-'.join([x.option_id.name for x in o.dimension_value_ids] or ['CONF'])_], but I don't understand this syntax. I want to in the code have the name of template and the color, like this :
Internal Reference : Bicycle Color - Black
Internal Reference : Bicycle Color - Blue
If I could change the Code Generator to do this above, I would have the unique Internal Reference....
Someone understand this syntax? How can I join the name of template with the name of the color ?
Thanks
↧