[IMP] product: Change 'default_code' to a compute field

Goal : Don't display the internal reference from one of the product template
as it was currently the case, because it was a related field to a one2many.
Here, we use the same behavior as for weight,volume or standard price fields.
If only 1 variant, i.e. no variant used, take the default_code from the template
If more than 1 variant, do not display anything.
This commit is contained in:
Yannick Tivisse
2015-11-06 14:51:17 +01:00
parent 7c9d93f0ef
commit fac4127470
+5 -1
View File
@@ -512,7 +512,11 @@ class product_template(osv.osv):
# related to display product product information if is_product_variant
'barcode': fields.related('product_variant_ids', 'barcode', type='char', string='Barcode', oldname='ean13'),
'default_code': fields.related('product_variant_ids', 'default_code', type='char', string='Internal Reference'),
'default_code': fields.function(_compute_product_template_field, fnct_inv=_set_product_template_field, multi='_compute_product_template_field', type='char', string='Internal Reference', store={
_name: (lambda s,c,u,i,t: i, ['product_variant_ids'], 10),
'product.product': (_get_template_id_from_product, ['product_tmpl_id', 'default_code'], 10),
}),
'item_ids': fields.one2many('product.pricelist.item', 'product_tmpl_id', 'Pricelist Items'),
}