Hello
I'm developing a module that insert some columns to the product.attribute and product.attribute.value, but when i make a product with 2 variants itś get not available on the e-shop. This doesn happen without my module installed.
My code:
class product_colorisa_attribute(osv.osv):
_inherit = "product.attribute.value"
_columns = {
'code' : fields.char('Codigo', size=3, required=True, help="Campo con capacidad de 3 caracteres, pero segun definicion de la codificacion de los productos ingresar unicamente 2 en caso de catalogar un Color, Sabor."),
'scode' : fields.char('Sub Codigo', size=2, required=False, help="")
}
class product_product(osv.osv):
_inherit = 'product.product'
def get_ref(self, cr, uid, ids,context=None):
if isinstance(ids, (list, tuple)) and not len(ids):
return []
if isinstance(ids, (long, int)):
ids = [ids]
reads = self.browse(cr, uid, ids)
res = []
for records in reads:
if records.categ_id.code:
ref = records.categ_id.code + '' + records.linea_id.code + '' + records.marca_id.code
for attribute in records.attribute_value_ids:
print attribute.code
if attribute.code:
ref = ref + '' + attribute.code
if ref:
print ref
res.append((records['id'], ref))
return res
def _get_ref(self, cr, uid, ids, prop, unknow_none, context=None):
res = self.get_ref(cr, uid, ids, context=context)
return dict(res)
_columns = {
'ref' : fields.function(_get_ref, type='char', string='Internal Reference', store=True ),
}
Thanks for anything and forgive my english