# HG changeset patch
# User Ranjith S R <ranjith@qualiantech.com>
# Date 1462191659 -19800
#      Mon May 02 17:50:59 2016 +0530
# Node ID 6df4bef1b2624b00176b11d8cb170c01aa126417
# Parent  0f16938cf3916adc1927b95b3b800b66065b6577
Fixes issue 32823 : Removed multi receipt line selection event

Added condition to display Toolbar buttons(+, -, quantity) on receipt line selection events

diff -r 0f16938cf391 -r 6df4bef1b262 web/org.openbravo.retail.posterminal/js/components/renderorderline.js
--- a/web/org.openbravo.retail.posterminal/js/components/renderorderline.js	Wed Apr 27 08:59:39 2016 +0000
+++ b/web/org.openbravo.retail.posterminal/js/components/renderorderline.js	Mon May 02 17:50:59 2016 +0530
@@ -1,6 +1,6 @@
 /*
  ************************************************************************************
- * Copyright (C) 2013-2015 Openbravo S.L.U.
+ * Copyright (C) 2013-2016 Openbravo S.L.U.
  * Licensed under the Openbravo Commercial License version 1.0
  * You may obtain a copy of the License at http://www.openbravo.com/legal/obcl.html
  * or in the legal folder of this module distribution.
@@ -20,9 +20,6 @@
   tap: function () {
     this.model.trigger('selected', this.model);
     this.model.trigger('click', this.model);
-    this.bubble('onReceiptLineSelected', {
-      product: this.model.get('product')
-    });
   },
   events: {
     onLineChecked: ''
diff -r 0f16938cf391 -r 6df4bef1b262 web/org.openbravo.retail.posterminal/js/pointofsale/view/editline.js
--- a/web/org.openbravo.retail.posterminal/js/pointofsale/view/editline.js	Wed Apr 27 08:59:39 2016 +0000
+++ b/web/org.openbravo.retail.posterminal/js/pointofsale/view/editline.js	Mon May 02 17:50:59 2016 +0530
@@ -1,6 +1,6 @@
 /*
  ************************************************************************************
- * Copyright (C) 2012-2013 Openbravo S.L.U.
+ * Copyright (C) 2012-2016 Openbravo S.L.U.
  * Licensed under the Openbravo Commercial License version 1.0
  * You may obtain a copy of the License at http://www.openbravo.com/legal/obcl.html
  * or in the legal folder of this module distribution.
@@ -282,7 +282,8 @@
     onDeleteLine: '',
     onEditLine: '',
     onReturnLine: '',
-    onShowPopup: ''
+    onShowPopup: '',
+    onReceiptLineSelected: ''
   },
   handlers: {
     onCheckBoxBehaviorForTicketLine: 'checkBoxBehavior',
@@ -295,11 +296,14 @@
       //are removed. Because of it, the callback for the selected event are saved
       //and then recovered.
       this.selectedCallbacks = this.receipt.get('lines')._callbacks.selected;
+      this.clickCallbacks = this.receipt.get('lines')._callbacks.click;
       this.receipt.get('lines').off('selected');
+      this.receipt.get('lines').off('click');
       this.render();
     } else {
       //WARN! recover the callbacks for the selected events
       this.receipt.get('lines')._callbacks.selected = this.selectedCallbacks;
+      this.receipt.get('lines')._callbacks.click = this.clickCallbacks;
 
       if (this.receipt.get('lines').length > 0) {
         var line = this.receipt.get('lines').at(0);
@@ -461,10 +465,16 @@
   },
   receiptChanged: function () {
     this.inherited(arguments);
-
     this.line = null;
-
-    this.receipt.get('lines').on('selected', this.selectedListener, this);
+    var me = this;
+    this.receipt.get('lines').on('selected', function (lineSelected) {
+      if (lineSelected) {
+        me.selectedListener(lineSelected);
+        me.doReceiptLineSelected({
+          product: lineSelected.get('product')
+        });
+      }
+    }, this);
   },
 
   render: function () {
diff -r 0f16938cf391 -r 6df4bef1b262 web/org.openbravo.retail.posterminal/js/pointofsale/view/pointofsale.js
--- a/web/org.openbravo.retail.posterminal/js/pointofsale/view/pointofsale.js	Wed Apr 27 08:59:39 2016 +0000
+++ b/web/org.openbravo.retail.posterminal/js/pointofsale/view/pointofsale.js	Mon May 02 17:50:59 2016 +0530
@@ -1,6 +1,6 @@
 /*
  ************************************************************************************
- * Copyright (C) 2013-2015 Openbravo S.L.U.
+ * Copyright (C) 2013-2016 Openbravo S.L.U.
  * Licensed under the Openbravo Commercial License version 1.0
  * You may obtain a copy of the License at http://www.openbravo.com/legal/obcl.html
  * or in the legal folder of this module distribution.
@@ -1002,29 +1002,20 @@
     this.waterfall('onChangePricelist', inEvent);
   },
   receiptLineSelected: function (inSender, inEvent) {
-    if (inEvent.product.get('groupProduct')) {
-      // The line selected is a grouped product, so enable the quantity button
-      this.waterfall('onEnableQtyButton', {
-        enable: true
-      });
-      this.waterfall('onEnablePlusButton', {
-        enable: true
-      });
-      this.waterfall('onEnableMinusButton', {
-        enable: true
-      });
-    } else {
-      // The line selected is not a grouped product, so disable the quantity button
-      this.waterfall('onEnableQtyButton', {
-        enable: false
-      });
-      this.waterfall('onEnablePlusButton', {
-        enable: false
-      });
-      this.waterfall('onEnableMinusButton', {
-        enable: false
-      });
+    var enableButton = true,
+        product = inEvent.product;
+    if (!product.get('groupProduct') || (product.get('productType') === 'S' && product.get('isLinkedToProduct'))) {
+      enableButton = false;
     }
+    this.waterfall('onEnableQtyButton', {
+      enable: enableButton
+    });
+    this.waterfall('onEnablePlusButton', {
+      enable: enableButton
+    });
+    this.waterfall('onEnableMinusButton', {
+      enable: enableButton
+    });
     OB.UTIL.HookManager.executeHooks('OBPOS_LineSelected', {
       product: inEvent.product,
       context: this
diff -r 0f16938cf391 -r 6df4bef1b262 web/org.openbravo.retail.posterminal/js/pointofsale/view/toolbar-right.js
--- a/web/org.openbravo.retail.posterminal/js/pointofsale/view/toolbar-right.js	Wed Apr 27 08:59:39 2016 +0000
+++ b/web/org.openbravo.retail.posterminal/js/pointofsale/view/toolbar-right.js	Mon May 02 17:50:59 2016 +0530
@@ -1,6 +1,6 @@
 /*
  ************************************************************************************
- * Copyright (C) 2012-2015 Openbravo S.L.U.
+ * Copyright (C) 2012-2016 Openbravo S.L.U.
  * Licensed under the Openbravo Commercial License version 1.0
  * You may obtain a copy of the License at http://www.openbravo.com/legal/obcl.html
  * or in the legal folder of this module distribution.
@@ -375,6 +375,9 @@
   },
   init: function (model) {
     this.model = model;
+    this.model.get('order').get('lines').on('selected', function (lineSelected) {
+      this.currentLine = lineSelected;
+    }, this);
     //    var me = this;
     //    this.model.get('multiOrders').on('change:isMultiOrders', function (model) {
     //      me.doRightToolbarDisabled({
@@ -386,10 +389,6 @@
     this.setDisabled(inEvent.status);
   },
   tap: function (options) {
-    this.model.get('order').get('lines').on('selected', function (lineSelected) {
-      this.currentLine = lineSelected;
-    }, this);
-
     if (!options.isManual) {
       // The tap was not manual. So consider the last line added
       var lines = this.model.get('order').get('lines');
