From 1ca616ddfdee927b16f8f19817c612219b402aa8 Mon Sep 17 00:00:00 2001 From: "Amit Bhavsar (Open ERP)" Date: Fri, 11 Oct 2013 13:02:25 +0530 Subject: [PATCH] [imp] changes of cms branch. bzr revid: amb@tinyerp.com-20131011073225-6xayq84ov0rsnffs --- addons/product/product.py | 57 ++++++------ addons/product/product_view.xml | 149 ++++++++++++++++++-------------- 2 files changed, 114 insertions(+), 92 deletions(-) diff --git a/addons/product/product.py b/addons/product/product.py index 71f1eeffaf3..259afd676bb 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): @@ -519,15 +548,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)]) @@ -572,25 +592,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/product/product_view.xml b/addons/product/product_view.xml index 0256b9f3d53..2d57ddedb00 100644 --- a/addons/product/product_view.xml +++ b/addons/product/product_view.xml @@ -694,74 +694,95 @@ product.template
-