Sharoon Thomas
15 years ago
committed by
sebastien beau
5 changed files with 185 additions and 0 deletions
-
19product_images_olbs/__init__.py
-
35product_images_olbs/__terp__.py
-
28product_images_olbs/product.py
-
45product_images_olbs/product_images.py
-
58product_images_olbs/views/product_images_view.xml
@ -0,0 +1,19 @@ |
|||
######################################################################### |
|||
# Copyright (C) 2009 Sharoon Thomas Open Labs Business Solutions # |
|||
# # |
|||
#This program is free software: you can redistribute it and/or modify # |
|||
#it under the terms of the GNU General Public License as published by # |
|||
#the Free Software Foundation, either version 3 of the License, or # |
|||
#(at your option) any later version. # |
|||
# # |
|||
#This program is distributed in the hope that it will be useful, # |
|||
#but WITHOUT ANY WARRANTY; without even the implied warranty of # |
|||
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # |
|||
#GNU General Public License for more details. # |
|||
# # |
|||
#You should have received a copy of the GNU General Public License # |
|||
#along with this program. If not, see <http://www.gnu.org/licenses/>. # |
|||
######################################################################### |
|||
|
|||
import product_images |
|||
import product |
@ -0,0 +1,35 @@ |
|||
######################################################################### |
|||
# Copyright (C) 2009 Sharoon Thomas, Open Labs Business solutions # |
|||
# # |
|||
#This program is free software: you can redistribute it and/or modify # |
|||
#it under the terms of the GNU General Public License as published by # |
|||
#the Free Software Foundation, either version 3 of the License, or # |
|||
#(at your option) any later version. # |
|||
# # |
|||
#This program is distributed in the hope that it will be useful, # |
|||
#but WITHOUT ANY WARRANTY; without even the implied warranty of # |
|||
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # |
|||
#GNU General Public License for more details. # |
|||
# # |
|||
#You should have received a copy of the GNU General Public License # |
|||
#along with this program. If not, see <http://www.gnu.org/licenses/>. # |
|||
######################################################################### |
|||
|
|||
{ |
|||
"name" : "Product Image Gallery", |
|||
"version" : "0.1 ", |
|||
"author" : "Sharoon Thomas, Open Labs Business Solutions", |
|||
"website" : "http://openlabs.co.in/", |
|||
"category" : "Added functionality - Product Extension", |
|||
"depends" : ['base','product'], |
|||
"description": """ |
|||
""", |
|||
"init_xml": [], |
|||
"update_xml": [ |
|||
'views/product_images_view.xml', |
|||
], |
|||
"installable": True, |
|||
"active": False, |
|||
} |
|||
|
|||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: |
@ -0,0 +1,28 @@ |
|||
######################################################################### |
|||
# Copyright (C) 2009 Sharoon Thomas, Open Labs Business solutions # |
|||
# # |
|||
#This program is free software: you can redistribute it and/or modify # |
|||
#it under the terms of the GNU General Public License as published by # |
|||
#the Free Software Foundation, either version 3 of the License, or # |
|||
#(at your option) any later version. # |
|||
# # |
|||
#This program is distributed in the hope that it will be useful, # |
|||
#but WITHOUT ANY WARRANTY; without even the implied warranty of # |
|||
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # |
|||
#GNU General Public License for more details. # |
|||
# # |
|||
#You should have received a copy of the GNU General Public License # |
|||
#along with this program. If not, see <http://www.gnu.org/licenses/>. # |
|||
######################################################################### |
|||
from osv import osv,fields |
|||
|
|||
class product_product(osv.osv): |
|||
_inherit = "product.product" |
|||
_columns = { |
|||
'image_ids':fields.one2many( |
|||
'product.images', |
|||
'product_id', |
|||
'Product Images' |
|||
) |
|||
} |
|||
product_product() |
@ -0,0 +1,45 @@ |
|||
######################################################################### |
|||
# Copyright (C) 2009 Sharoon Thomas, Open Labs Business solutions # |
|||
# # |
|||
#This program is free software: you can redistribute it and/or modify # |
|||
#it under the terms of the GNU General Public License as published by # |
|||
#the Free Software Foundation, either version 3 of the License, or # |
|||
#(at your option) any later version. # |
|||
# # |
|||
#This program is distributed in the hope that it will be useful, # |
|||
#but WITHOUT ANY WARRANTY; without even the implied warranty of # |
|||
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # |
|||
#GNU General Public License for more details. # |
|||
# # |
|||
#You should have received a copy of the GNU General Public License # |
|||
#along with this program. If not, see <http://www.gnu.org/licenses/>. # |
|||
######################################################################### |
|||
from osv import osv, fields |
|||
import base64 |
|||
|
|||
class ProductImages(osv.osv): |
|||
"Products Image gallery" |
|||
_name = "product.images" |
|||
_description = __doc__ |
|||
|
|||
def _get_image(self, cr, uid, ids, field_name, arg, context={}): |
|||
res = {} |
|||
for each in self.read(cr, uid, ids, ['link', 'filename', 'image']): |
|||
if each['link']: |
|||
f = open(each['filename'],'rb') |
|||
res[each['id']] = base64.encodestring(f.read()) |
|||
f.close() |
|||
else: |
|||
res[each['id']] = each['image'] |
|||
return res |
|||
|
|||
_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"), |
|||
'image':fields.binary('Image', filters='*.png,*.jpeg,*.gif'), |
|||
'filename':fields.char('File Location', size=250), |
|||
'preview':fields.function(_get_image, type="binary", method=True), |
|||
'comments':fields.text('Comments'), |
|||
'product_id':fields.many2one('product.product', 'Product') |
|||
} |
|||
ProductImages() |
@ -0,0 +1,58 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<openerp> |
|||
<data> |
|||
<record id="view_product_image_form" model="ir.ui.view"> |
|||
<field name="name">product.images.form</field> |
|||
<field name="model">product.images</field> |
|||
<field name="type">form</field> |
|||
<field name="arch" type="xml"> |
|||
<form string="Product Images"> |
|||
<notebook colspan="4"> |
|||
<page string="Image"> |
|||
<group col="4" colspan="4"> |
|||
<field name="name" colspan="2" /> |
|||
<field name="link" colspan="2" /> |
|||
</group> |
|||
<group col="4" colspan="4" attrs="{'invisible':[('link','!=',0)]}"> |
|||
<field name="image" colspan="4" /> |
|||
</group> |
|||
<group col="4" colspan="4" attrs="{'invisible':[('link','=',0)]}"> |
|||
<field name="filename" colspan="4" /> |
|||
</group> |
|||
<separator string="Preview (Only when saved)" colspan="4" /> |
|||
<field name="preview" widget="image" nolabel="1" colspan="4"/> |
|||
</page> |
|||
<page string="Comments"> |
|||
<field name="comments" nolabel="1" colspan="4" /> |
|||
</page> |
|||
</notebook> |
|||
</form> |
|||
</field> |
|||
</record> |
|||
<record id="view_product_image_tree" model="ir.ui.view"> |
|||
<field name="name">product.images.tree</field> |
|||
<field name="model">product.images</field> |
|||
<field name="type">tree</field> |
|||
<field name="arch" type="xml"> |
|||
<tree string="Product Images"> |
|||
<field name="name" select="1" /> |
|||
<field name="image" /> |
|||
<field name="comments" select="2" /> |
|||
</tree> |
|||
</field> |
|||
</record> |
|||
<record id="view_product_form_img_inh" model="ir.ui.view"> |
|||
<field name="name">product.product.images</field> |
|||
<field name="model">product.product</field> |
|||
<field name="inherit_id" ref="product.product_normal_form_view" /> |
|||
<field name="type">tree</field> |
|||
<field name="arch" type="xml"> |
|||
<xpath expr="/form/notebook" position="inside"> |
|||
<page string="Images"> |
|||
<field name="image_ids" nolabel="1" /> |
|||
</page> |
|||
</xpath> |
|||
</field> |
|||
</record> |
|||
</data> |
|||
</openerp> |
Write
Preview
Loading…
Cancel
Save
Reference in new issue