# HG changeset patch
# User Ranjith S R <ranjith@qualiantech.com>
# Date 1577192508 -19800
#      Tue Dec 24 18:31:48 2019 +0530
# Node ID c586aeb0fa5b22f4fe3a29beaa5d387599c21e0e
# Parent  f03f3f451a2a346c50d8ad7faea9c7243b197eba
Fixed issue 42600 : Location should be updated when changing Customer/Location

diff -r f03f3f451a2a -r c586aeb0fa5b web/org.openbravo.retail.posterminal/js/model/order.js
--- a/web/org.openbravo.retail.posterminal/js/model/order.js	Tue Dec 24 16:24:55 2019 +0530
+++ b/web/org.openbravo.retail.posterminal/js/model/order.js	Tue Dec 24 18:31:48 2019 +0530
@@ -5320,7 +5320,11 @@
               null,
               null,
               function(shipping, billing, locations) {
-                businessPartner.set('locationModel', billing);
+                businessPartner.set('locations', locations);
+                businessPartner.set(
+                  'locationModel',
+                  shipping ? shipping : billing
+                );
                 businessPartner.set('locationBillModel', billing);
                 businessPartner.set('locId', billing.get('id'));
                 businessPartner.set('locName', billing.get('name'));
@@ -5378,7 +5382,7 @@
             if (callback) {
               callback();
             }
-          } else {
+          } else if (businessPartner.get(lid)) {
             OB.Dal.get(
               OB.Model.BPLocation,
               businessPartner.get(lid),
@@ -5399,6 +5403,10 @@
                 OB.error(arguments);
               }
             );
+          } else {
+            if (callback) {
+              callback();
+            }
           }
         };
 
@@ -5416,7 +5424,11 @@
             null,
             null,
             function(shipping, billing, locations) {
-              businessPartner.set('locationModel', billing);
+              businessPartner.set('locations', locations);
+              businessPartner.set(
+                'locationModel',
+                shipping ? shipping : billing
+              );
               businessPartner.set('locationBillModel', billing);
               businessPartner.set('locId', billing.get('id'));
               businessPartner.set('locName', billing.get('name'));
