diff --git a/addons/product/product.py b/addons/product/product.py index 6e1128985aa..8c74217efac 100644 --- a/addons/product/product.py +++ b/addons/product/product.py @@ -289,6 +289,15 @@ class product_template(osv.osv): _name = "product.template" _description = "Product Template" + def _get_image(self, cr, uid, ids, name, args, context=None): + result = dict.fromkeys(ids, False) + for obj in self.browse(cr, uid, ids, context=context): + result[obj.id] = tools.image_get_resized_images(obj.image, avoid_resize_medium=True) + return result + + 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) + _columns = { 'name': fields.char('Name', size=128, required=True, translate=True, select=True), 'product_manager': fields.many2one('res.users','Product Manager'), @@ -328,6 +337,26 @@ class product_template(osv.osv): 'mes_type': fields.selection((('fixed', 'Fixed'), ('variable', 'Variable')), 'Measure Type'), 'seller_ids': fields.one2many('product.supplierinfo', 'product_id', 'Supplier'), 'company_id': fields.many2one('res.company', 'Company', select=1), + # image: all image fields are base64 encoded and PIL-supported + 'image': fields.binary("Image", + help="This field holds the image used as image for the product, limited to 1024x1024px."), + 'image_medium': fields.function(_get_image, fnct_inv=_set_image, + string="Medium-sized image", type="binary", multi="_get_image", + store={ + 'product.product': (lambda self, cr, uid, ids, c={}: ids, ['image'], 10), + }, + help="Medium-sized image of the product. It is automatically "\ + "resized as a 128x128px image, with aspect ratio preserved, "\ + "only when the image exceeds one of those sizes. Use this field in form views or some kanban views."), + 'image_small': fields.function(_get_image, fnct_inv=_set_image, + string="Small-sized image", type="binary", multi="_get_image", + store={ + 'product.product': (lambda self, cr, uid, ids, c={}: ids, ['image'], 10), + }, + help="Small-sized image of the product. It is automatically "\ + "resized as a 64x64px image, with aspect ratio preserved. "\ + "Use this field anywhere a small image is required."), + 'product_variant_ids': fields.one2many('product.product', 'product_tmpl_id', 'Product Variants'), } def _get_uom_id(self, cr, uid, *args): @@ -514,15 +543,6 @@ class product_product(osv.osv): return result - def _get_image(self, cr, uid, ids, name, args, context=None): - result = dict.fromkeys(ids, False) - for obj in self.browse(cr, uid, ids, context=context): - result[obj.id] = tools.image_get_resized_images(obj.image, avoid_resize_medium=True) - return result - - 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): result = set() template_ids = self.pool.get('product.product').search(cr, uid, [('product_tmpl_id', 'in', ids)]) @@ -567,25 +587,6 @@ class product_product(osv.osv): }, select=True), 'color': fields.integer('Color Index'), - # image: all image fields are base64 encoded and PIL-supported - 'image': fields.binary("Image", - help="This field holds the image used as image for the product, limited to 1024x1024px."), - 'image_medium': fields.function(_get_image, fnct_inv=_set_image, - string="Medium-sized image", type="binary", multi="_get_image", - store={ - 'product.product': (lambda self, cr, uid, ids, c={}: ids, ['image'], 10), - }, - help="Medium-sized image of the product. It is automatically "\ - "resized as a 128x128px image, with aspect ratio preserved, "\ - "only when the image exceeds one of those sizes. Use this field in form views or some kanban views."), - 'image_small': fields.function(_get_image, fnct_inv=_set_image, - string="Small-sized image", type="binary", multi="_get_image", - store={ - 'product.product': (lambda self, cr, uid, ids, c={}: ids, ['image'], 10), - }, - help="Small-sized image of the product. It is automatically "\ - "resized as a 64x64px image, with aspect ratio preserved. "\ - "Use this field anywhere a small image is required."), 'seller_info_id': fields.function(_calc_seller, type='many2one', relation="product.supplierinfo", string="Supplier Info", multi="seller_info"), 'seller_delay': fields.function(_calc_seller, type='integer', string='Supplier Lead Time', multi="seller_info", help="This is the average delay in days between the purchase order confirmation and the reception of goods for this product and for the default supplier. It is used by the scheduler to order requests based on reordering delays."), 'seller_qty': fields.function(_calc_seller, type='float', string='Supplier Quantity', multi="seller_info", help="This is minimum quantity to purchase from Main Supplier."), diff --git a/addons/website/views/views.xml b/addons/website/views/views.xml index 6920fc48aa0..87ba3d49e03 100644 --- a/addons/website/views/views.xml +++ b/addons/website/views/views.xml @@ -253,7 +253,7 @@