Browse Source

[REF]Refactored product image by openlabs

pull/186/head
Sharoon Thomas 15 years ago
committed by sebastien beau
parent
commit
76d22ccc4b
  1. 5
      product_images_olbs/__terp__.py
  2. 9
      product_images_olbs/product_images.py

5
product_images_olbs/__terp__.py

@ -23,6 +23,11 @@
"category" : "Added functionality - Product Extension",
"depends" : ['base','product'],
"description": """
This Module implements an Image Gallery for products.
You can add images against every product.
This module is generic but built for Magento ERP connector and
the upcoming e-commerce system for Open ERP by Open Labs
""",
"init_xml": [],
"update_xml": [

9
product_images_olbs/product_images.py

@ -22,20 +22,23 @@ class ProductImages(osv.osv):
_name = "product.images"
_description = __doc__
def _get_image(self, cr, uid, ids, field_name, arg, context={}):
def get_image(self, cr, uid, ids):
res = {}
for each in self.read(cr, uid, ids, ['link', 'filename', 'image']):
if each['link']:
f = open(each['filename'],'rb')
f = open(each['filename'], 'rb')
res[each['id']] = base64.encodestring(f.read())
f.close()
else:
res[each['id']] = each['image']
return res
def _get_image(self, cr, uid, ids, field_name, arg, context={}):
return self.get_image(cr,uid,ids)
_columns = {
'name':fields.char('Image Title', size=100, required=True),
'link':fields.boolean('Link?', help="Images can be linked from files in a remote web location (preffered) or on your file system"),
'link':fields.boolean('Link?', help="Images can be linked from files on your file system"),
'image':fields.binary('Image', filters='*.png,*.jpeg,*.gif'),
'filename':fields.char('File Location', size=250),
'preview':fields.function(_get_image, type="binary", method=True),

Loading…
Cancel
Save