[FIX] product: add store=dict to field name_template
Recompute the name_template field if the template changes. backport of41628fc
+f25c5d8
to 7.0 plus some optimisations in triggers Fixes #3277
This commit is contained in:
parent
a765876ffb
commit
d6daf5fa2f
|
@ -530,6 +530,10 @@ class product_product(osv.osv):
|
|||
def _set_image(self, cr, uid, id, name, value, args, context=None):
|
||||
return self.write(cr, uid, [id], {'image': tools.image_resize_image_big(value)}, context=context)
|
||||
|
||||
def _get_name_template_ids(self, cr, uid, ids, context=None):
|
||||
template_ids = self.pool.get('product.product').search(cr, uid, [('product_tmpl_id', 'in', ids)])
|
||||
return list(set(template_ids))
|
||||
|
||||
_defaults = {
|
||||
'active': lambda *a: 1,
|
||||
'price_extra': lambda *a: 0.0,
|
||||
|
@ -561,7 +565,11 @@ class product_product(osv.osv):
|
|||
'price_extra': fields.float('Variant Price Extra', digits_compute=dp.get_precision('Product Price')),
|
||||
'price_margin': fields.float('Variant Price Margin', digits_compute=dp.get_precision('Product Price')),
|
||||
'pricelist_id': fields.dummy(string='Pricelist', relation='product.pricelist', type='many2one'),
|
||||
'name_template': fields.related('product_tmpl_id', 'name', string="Template Name", type='char', size=128, store=True, select=True),
|
||||
'name_template': fields.related('product_tmpl_id', 'name', string="Template Name", type='char', size=128, store={
|
||||
'product.template': (_get_name_template_ids, ['name'], 10),
|
||||
'product.product': (lambda self, cr, uid, ids, c=None: ids, ['product_tmpl_id'], 10),
|
||||
|
||||
}, select=True),
|
||||
'color': fields.integer('Color Index'),
|
||||
# image: all image fields are base64 encoded and PIL-supported
|
||||
'image': fields.binary("Image",
|
||||
|
|
Loading…
Reference in New Issue