[merge] pos improvements

bzr revid: nicolas.vanhoren@openerp.com-20120103155315-zsksz10dy0i8vfpm
This commit is contained in:
niv-openerp
2012-01-03 16:53:15 +01:00
5 changed files with 154 additions and 114 deletions
+33 -1
View File
@@ -22,6 +22,10 @@
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
@@ -727,12 +731,40 @@ 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.binary('Product Image, must be 50x50', help="Use an image size of 50x50."),
'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.")
}
File diff suppressed because one or more lines are too long
+1 -2
View File
@@ -125,8 +125,7 @@
}
.point-of-sale #neworder-button {
width: 32px;
padding: 1px;
font-size: 23px;
padding: 4px 10px;
}
.point-of-sale #loggedas {
float: right;
+13 -3
View File
@@ -364,6 +364,7 @@ openerp.point_of_sale = function(db) {
step: 'products',
};
Order.prototype.initialize = function() {
this.set({creationDate: new Date});
this.set({
orderLines: new OrderlineCollection
});
@@ -742,7 +743,12 @@ openerp.point_of_sale = function(db) {
setValue: function(val) {
var param = {};
param[this.numpadState.get('mode')] = val;
this.shop.get('selectedOrder').selected.set(param);
var order = this.shop.get('selectedOrder');
if (order.get('orderLines').length !== 0) {
order.selected.set(param);
} else {
this.shop.get('selectedOrder').destroy();
}
},
changeSelectedOrder: function() {
this.currentOrderLines.unbind();
@@ -1019,7 +1025,11 @@ openerp.point_of_sale = function(db) {
render_element: function() {
this.$element.html(qweb_template('pos-receipt-view'));
$('button#pos-finish-order', this.$element).click(_.bind(this.finishOrder, this));
$('button#print-the-ticket', this.$element).click(function(){window.print();});
$('button#print-the-ticket', this.$element).click(_.bind(this.print, this));
},
print: function() {
window.print();
this.finishOrder();
},
finishOrder: function() {
this.shop.get('selectedOrder').destroy();
@@ -1077,7 +1087,7 @@ openerp.point_of_sale = function(db) {
this.order.destroy();
},
render_element: function() {
this.$element.html(this.template_fct(this.order.toJSON()));
this.$element.html(this.template_fct({widget:this}));
this.$element.addClass('order-selector-button');
}
});
+1 -2
View File
@@ -231,8 +231,7 @@
<br />
</t>
<t t-name="pos-order-selector-button-template">
<button class="select-order">Order</button>
<button class="close-order">X</button>
<button class="select-order"><t t-esc="widget.order.get('creationDate').toString('t')"/></button>
</t>
<t t-name="pos-receipt-view">
<div id="receipt-screen" class="step-screen" style="display:none">