[FIX] website_sale: Unable to customize image from grid of products. Add an option for the image qweb widget to resize and the views can add python data in widget options

This commit is contained in:
Christophe Matthieu
2015-01-16 16:38:09 +01:00
parent 031b83d9e7
commit e42995b614
4 changed files with 8 additions and 2 deletions
+3
View File
@@ -341,6 +341,9 @@ class Image(orm.AbstractModel):
max_size = '%sx%s' % (max_width, max_height)
src = self.pool['website'].image_url(cr, uid, record, field_name, max_size)
if options.get('resize'):
src = "%s/%s" % (src, options.get('resize'))
img = '<img class="%s" src="%s" style="%s"/>' % (classes, src, options.get('style', ''))
return ir_qweb.HTMLSafe(img)
@@ -42,6 +42,7 @@
$('<li data-style="'+data[k]['id']+'" data-toggle_class="'+data[k]['html_class']+'"/>')
.append( $('<a/>').text(data[k]['name']) ));
}
self.set_active();
});
this.bind_resize();
+1 -1
View File
@@ -77,7 +77,7 @@
</div>
<div class="oe_product_image">
<a itemprop="url" t-att-href="keep('/shop/product/%s' % slug(product), page=(pager['page']['num'] if pager['page']['num']>1 else None))">
<img itemprop="image" class="img img-responsive" t-att-src="website.image_url(product, 'image', None if product_image_big else '300x300')"/>
<span itemprop="image" t-field="product.image" t-field-options='{"widget": "image" #{None if product_image_big else ", \"resize\": \"300x300\""}}'/>
</a>
</div>
<section>
+3 -1
View File
@@ -476,7 +476,9 @@ class QWeb(orm.AbstractModel):
record = self.eval_object(record, qwebcontext)
field = record._fields[field_name]
options = json.loads(template_attributes.get('field-options') or '{}')
foptions = self.eval_format(template_attributes.get('field-options') or '{}', qwebcontext)
options = json.loads(foptions)
field_type = get_field_type(field, options)
converter = self.get_converter_for(field_type)