summaryrefslogtreecommitdiff
path: root/addons
diff options
context:
space:
mode:
authorFrédéric van der Essen <fvdessen@gmail.com>2015-04-23 16:34:54 +0200
committerFrédéric van der Essen <fvdessen@gmail.com>2015-05-04 14:13:43 +0200
commitebeb3caa62b0a6664052d47d9dea5795f55f8d21 (patch)
tree55521a4a771f69951566468964e6bb5c3504c692 /addons
parentd0fb760709ddd0acb183139b92bbba46092a1493 (diff)
[IMP] pos_restaurant: better feedback for skipped orderlines (kitchen printing)
Diffstat (limited to 'addons')
-rw-r--r--addons/point_of_sale/static/src/css/pos.css7
-rw-r--r--addons/point_of_sale/static/src/js/db.js19
-rw-r--r--addons/point_of_sale/static/src/js/screens.js4
-rw-r--r--addons/pos_restaurant/static/src/css/restaurant.css3
-rw-r--r--addons/pos_restaurant/static/src/js/floors.js2
-rw-r--r--addons/pos_restaurant/static/src/js/multiprint.js53
-rw-r--r--addons/pos_restaurant/static/src/xml/floors.xml2
7 files changed, 69 insertions, 21 deletions
diff --git a/addons/point_of_sale/static/src/css/pos.css b/addons/point_of_sale/static/src/css/pos.css
index 4ce4ea18eb1..04d21b770a7 100644
--- a/addons/point_of_sale/static/src/css/pos.css
+++ b/addons/point_of_sale/static/src/css/pos.css
@@ -583,10 +583,15 @@ td {
.pos .control-button.highlight,
.pos .button.highlight {
background: #6EC89B !important;
- /* border: solid 1px #6EC89B !important; */
border: solid 1px #64AF8A !important;
color: white !important;
}
+.pos .control-button.altlight,
+.pos .button.altlight {
+ background: #7F82AC !important;
+ border: solid 1px #756A99 !important;
+ color: white !important;
+}
.pos .control-button.disabled,
.pos .control-button.disabled:active{
background: #e2e2e2;
diff --git a/addons/point_of_sale/static/src/js/db.js b/addons/point_of_sale/static/src/js/db.js
index 4e69f748a73..cfd842f86da 100644
--- a/addons/point_of_sale/static/src/js/db.js
+++ b/addons/point_of_sale/static/src/js/db.js
@@ -399,6 +399,25 @@ var PosDB = core.Class.extend({
}
return results;
},
+ /* from a product id, and a list of category ids, returns
+ * true if the product belongs to one of the provided category
+ * or one of its child categories.
+ */
+ is_product_in_category: function(category_ids, product_id) {
+ if (!(category_ids instanceof Array)) {
+ category_ids = [category_ids];
+ }
+ var cat = this.get_product_by_id(product_id).pos_categ_id[0];
+ while (cat) {
+ for (var i = 0; i < category_ids.length; i++) {
+ if (cat == category_ids[i]) { // The == is important, ids may be strings
+ return true;
+ }
+ }
+ cat = this.get_category_parent_id(cat);
+ }
+ return false;
+ },
/* paid orders */
add_order: function(order){
diff --git a/addons/point_of_sale/static/src/js/screens.js b/addons/point_of_sale/static/src/js/screens.js
index 5c3349cda07..f2ffc611dab 100644
--- a/addons/point_of_sale/static/src/js/screens.js
+++ b/addons/point_of_sale/static/src/js/screens.js
@@ -847,6 +847,10 @@ var ActionButtonWidget = PosBaseWidget.extend({
highlight: function(highlight){
this.$el.toggleClass('highlight',!!highlight);
},
+ // alternative highlight color
+ altlight: function(altlight){
+ this.$el.toggleClass('altlight',!!altlight);
+ },
});
/* -------- The Product Screen -------- */
diff --git a/addons/pos_restaurant/static/src/css/restaurant.css b/addons/pos_restaurant/static/src/css/restaurant.css
index ec6c2f2f365..6e34f6aaa27 100644
--- a/addons/pos_restaurant/static/src/css/restaurant.css
+++ b/addons/pos_restaurant/static/src/css/restaurant.css
@@ -251,6 +251,9 @@
.floor-map .table .order-count.notify-printing {
background: red;
}
+.floor-map .table .order-count.notify-skipped {
+ background: blue;
+}
/* ------ FLOOR BUTTON IN THE ORDER SELECTOR ------- */
diff --git a/addons/pos_restaurant/static/src/js/floors.js b/addons/pos_restaurant/static/src/js/floors.js
index bbf102fc13f..e1075ab34d6 100644
--- a/addons/pos_restaurant/static/src/js/floors.js
+++ b/addons/pos_restaurant/static/src/js/floors.js
@@ -301,6 +301,8 @@ var TableWidget = PosBaseWidget.extend({
if (orders[i].hasChangesToPrint()) {
notifications.printing = true;
break;
+ } else if (orders[i].hasSkippedChanges()) {
+ notifications.skipped = true;
}
}
return notifications;
diff --git a/addons/pos_restaurant/static/src/js/multiprint.js b/addons/pos_restaurant/static/src/js/multiprint.js
index 4f218dbdaf6..19c76a30a4c 100644
--- a/addons/pos_restaurant/static/src/js/multiprint.js
+++ b/addons/pos_restaurant/static/src/js/multiprint.js
@@ -49,13 +49,21 @@ models.load_models({
}
self.printers = [];
+ self.printers_categories = {}; // list of product categories that belong to
+ // one or more order printer
+
for(var i = 0; i < printers.length; i++){
if(active_printers[printers[i].id]){
var printer = new Printer(self,{url:'http://'+printers[i].proxy_ip+':8069'});
printer.config = printers[i];
self.printers.push(printer);
+
+ for (var j = 0; j < printer.config.product_categories_ids.length; j++) {
+ self.printers_categories[printer.config.product_categories_ids[j]] = true;
+ }
}
}
+ self.printers_categories = _.keys(self.printers_categories);
self.config.iface_printers = !!self.printers.length;
},
});
@@ -71,7 +79,10 @@ models.Orderline = models.Orderline.extend({
if (typeof this.mp_dirty === 'undefined') {
// mp dirty is true if this orderline has changed
// since the last kitchen print
- this.mp_dirty = true;
+ // it's left undefined if the orderline does not
+ // need to be printed to a printer.
+
+ this.mp_dirty = this.printable() || undefined;
}
if (!this.mp_skip) {
// mp_skip is true if the cashier want this orderline
@@ -79,6 +90,10 @@ models.Orderline = models.Orderline.extend({
this.mp_skip = false;
}
},
+ // can this orderline be potentially printed ?
+ printable: function() {
+ return this.pos.db.is_product_in_category(this.pos.printers_categories, this.get_product().id);
+ },
init_from_JSON: function(json) {
_super_orderline.init_from_JSON.apply(this,arguments);
this.mp_dirty = json.mp_dirty;
@@ -91,7 +106,7 @@ models.Orderline = models.Orderline.extend({
return json;
},
set_quantity: function(quantity) {
- if (this.pos.config.iface_printers && quantity !== this.quantity) {
+ if (this.pos.config.iface_printers && quantity !== this.quantity && this.printable()) {
this.mp_dirty = true;
}
_super_orderline.set_quantity.apply(this,arguments);
@@ -237,31 +252,19 @@ models.Order = models.Order.extend({
// products that belong to one of the categories supplied as a parameter
var self = this;
- function product_in_category(product_id){
- var cat = self.pos.db.get_product_by_id(product_id).pos_categ_id[0];
- while(cat){
- for(var i = 0; i < categories.length; i++){
- if(cat === categories[i]){
- return true;
- }
- }
- cat = self.pos.db.get_category_parent_id(cat);
- }
- return false;
- }
var _add = [];
var _rem = [];
for(var i = 0; i < add.length; i++){
- if(product_in_category(add[i].id)){
+ if(self.pos.db.is_product_in_category(categories,add[i].id)){
_add.push(add[i]);
}
}
add = _add;
for(var i = 0; i < rem.length; i++){
- if(product_in_category(rem[i].id)){
+ if(self.pos.db.is_product_in_category(categories,rem[i].id)){
_rem.push(rem[i]);
}
}
@@ -307,6 +310,15 @@ models.Order = models.Order.extend({
}
return false;
},
+ hasSkippedChanges: function() {
+ var orderlines = this.get_orderlines();
+ for (var i = 0; i < orderlines.length; i++) {
+ if (orderlines[i].mp_skip) {
+ return true;
+ }
+ }
+ return false;
+ },
export_as_JSON: function(){
var json = _super_order.export_as_JSON.apply(this,arguments);
json.multiprint_resume = this.saved_resume;
@@ -341,9 +353,12 @@ screens.OrderWidget.include({
update_summary: function(){
this._super();
var changes = this.pos.get_order().hasChangesToPrint();
- if (this.getParent().action_buttons &&
- this.getParent().action_buttons.submit_order) {
- this.getParent().action_buttons.submit_order.highlight(changes);
+ var skipped = changes ? false : this.pos.get_order().hasSkippedChanges();
+ var buttons = this.getParent().action_buttons;
+
+ if (buttons && buttons.submit_order) {
+ buttons.submit_order.highlight(changes);
+ buttons.submit_order.altlight(skipped);
}
},
});
diff --git a/addons/pos_restaurant/static/src/xml/floors.xml b/addons/pos_restaurant/static/src/xml/floors.xml
index 63a5574291e..39825fab86f 100644
--- a/addons/pos_restaurant/static/src/xml/floors.xml
+++ b/addons/pos_restaurant/static/src/xml/floors.xml
@@ -35,7 +35,7 @@
t-att-style='"height: " + Math.ceil(widget.fill * 100) + "%;"'
></span>
<t t-if='widget.order_count'>
- <span t-att-class='"order-count " + (widget.notifications.printing ? "notify-printing":"")'><t t-esc='widget.order_count'/></span>
+ <span t-att-class='"order-count " + (widget.notifications.printing ? "notify-printing":"") + (widget.notifications.skipped ? "notify-skipped" : "")'><t t-esc='widget.order_count'/></span>
</t>
<span class='label'>
<t t-esc='widget.table.name' />