[MERGE] lp:908750 (pos: remove redundant field 'img', and use 'product_image' instead)
bzr revid: rco@openerp.com-20120105085658-1epi60v4s3742vqv
This commit is contained in:
commit
82ff85e770
|
@ -22,10 +22,6 @@
|
|||
import time
|
||||
from datetime import datetime
|
||||
from dateutil.relativedelta import relativedelta
|
||||
import PIL
|
||||
import io
|
||||
import base64
|
||||
import StringIO
|
||||
|
||||
import netsvc
|
||||
from osv import fields, osv
|
||||
|
@ -282,7 +278,7 @@ class pos_order(osv.osv):
|
|||
('user_id', '=', uid),
|
||||
('state', '=', 'open')], context=context)
|
||||
if len(statement_id) == 0:
|
||||
raise osv.except_osv(_('Error !'), _('You have to open at least one cashbox.'))
|
||||
raise osv.except_osv(_('Error !'), _('You have to open at least one cashbox'))
|
||||
if statement_id:
|
||||
statement_id = statement_id[0]
|
||||
args['statement_id'] = statement_id
|
||||
|
@ -731,40 +727,11 @@ class pos_category(osv.osv):
|
|||
}
|
||||
pos_category()
|
||||
|
||||
_IMAGE_SIZE = 100,120
|
||||
|
||||
class product_product(osv.osv):
|
||||
_inherit = 'product.product'
|
||||
|
||||
def _get_img(self, cr, uid, ids, field_name, arg, context=None):
|
||||
context = context or {}
|
||||
bin_size = context.get('bin_size', False)
|
||||
context = dict(context, bin_size = False)
|
||||
products = self.browse(cr, uid, ids, context=context)
|
||||
result = {}
|
||||
for product in products:
|
||||
image64 = product.product_image
|
||||
if not image64:
|
||||
result[product.id] = False
|
||||
continue
|
||||
image_bin = base64.decodestring(image64)
|
||||
image_stream = io.BytesIO(image_bin)
|
||||
im = PIL.Image.open(image_stream)
|
||||
im.thumbnail(_IMAGE_SIZE, PIL.Image.ANTIALIAS)
|
||||
nimage_stream = StringIO.StringIO()
|
||||
im.save(nimage_stream, format="JPEG")
|
||||
nimage_bin = nimage_stream.getvalue()
|
||||
if not bin_size:
|
||||
result[product.id] = base64.encodestring(nimage_bin)
|
||||
else:
|
||||
result[product.id] = nimage_bin.length
|
||||
return result
|
||||
|
||||
_columns = {
|
||||
'income_pdt': fields.boolean('PoS Cash Input', help="This is a product you can use to put cash into a statement for the point of sale backend."),
|
||||
'expense_pdt': fields.boolean('PoS Cash Output', help="This is a product you can use to take cash from a statement for the point of sale backend, exemple: money lost, transfer to bank, etc."),
|
||||
'img': fields.function(_get_img, method=True, type="binary", string='Product Image',
|
||||
store = {'product.product': (lambda self, cr, uid, ids, c=None: ids, ['product_image'], 10)}),
|
||||
'pos_categ_id': fields.many2one('pos.category','PoS Category',
|
||||
help="If you want to sell this product through the point of sale, select the category it belongs to.")
|
||||
}
|
||||
|
|
|
@ -86,7 +86,7 @@ openerp.point_of_sale = function(db) {
|
|||
}, this));
|
||||
}, this));
|
||||
$.when(this.fetch('pos.category', ['name', 'parent_id', 'child_id']),
|
||||
this.fetch('product.product', ['name', 'list_price', 'pos_categ_id', 'taxes_id', 'img'], [['pos_categ_id', '!=', 'false']]),
|
||||
this.fetch('product.product', ['name', 'list_price', 'pos_categ_id', 'taxes_id', 'product_image'], [['pos_categ_id', '!=', 'false']]),
|
||||
this.fetch('account.bank.statement', ['account_id', 'currency', 'journal_id', 'state', 'name'],
|
||||
[['state', '=', 'open'], ['user_id', '=', this.session.uid]]),
|
||||
this.fetch('account.journal', ['auto_cash', 'check_dtls', 'currency', 'name', 'type']),
|
||||
|
|
|
@ -188,7 +188,7 @@
|
|||
<t t-name="pos-product-template">
|
||||
<a href="#">
|
||||
<div class="product-img">
|
||||
<img t-att-src="'data:image/gif;base64,'+ img" />
|
||||
<img t-att-src="'data:image/gif;base64,'+ product_image" />
|
||||
<span class="price-tag">
|
||||
<t t-esc="format_amount(list_price)"/>
|
||||
</span>
|
||||
|
|
Loading…
Reference in New Issue