[FIX]product: add store function to name_template
bzr revid: csn@openerp.com-20130415102030-tbzcee5yujmw3r0l
This commit is contained in:
commit
9ee0b5dacf
|
@ -523,6 +523,14 @@ class product_product(osv.osv):
|
||||||
def _set_image(self, cr, uid, id, name, value, args, context=None):
|
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)
|
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):
|
||||||
|
result = set()
|
||||||
|
for template in self.browse(cr, uid, ids, context=context):
|
||||||
|
template_ids = self.pool.get('product.product').search(cr, uid, [('product_tmpl_id','=',template.id)])
|
||||||
|
for el in template_ids:
|
||||||
|
result.add(el)
|
||||||
|
return list(result)
|
||||||
|
|
||||||
_defaults = {
|
_defaults = {
|
||||||
'active': lambda *a: 1,
|
'active': lambda *a: 1,
|
||||||
'price_extra': lambda *a: 0.0,
|
'price_extra': lambda *a: 0.0,
|
||||||
|
@ -554,7 +562,11 @@ class product_product(osv.osv):
|
||||||
'price_extra': fields.float('Variant Price Extra', digits_compute=dp.get_precision('Product Price')),
|
'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')),
|
'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'),
|
'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={}: ids, [], 10),
|
||||||
|
|
||||||
|
}, select=True),
|
||||||
'color': fields.integer('Color Index'),
|
'color': fields.integer('Color Index'),
|
||||||
# image: all image fields are base64 encoded and PIL-supported
|
# image: all image fields are base64 encoded and PIL-supported
|
||||||
'image': fields.binary("Image",
|
'image': fields.binary("Image",
|
||||||
|
|
Loading…
Reference in New Issue