Attached Files | multiplerequest.png [^] (234,584 bytes) 2017-01-23 10:41
posterminal_35025.diff [^] (2,063 bytes) 2017-01-23 13:52 [Show Content] [Hide Content]diff --git a/web/org.openbravo.retail.posterminal/js/components/modalreceiptproperties.js b/web/org.openbravo.retail.posterminal/js/components/modalreceiptproperties.js
--- a/web/org.openbravo.retail.posterminal/js/components/modalreceiptproperties.js
+++ b/web/org.openbravo.retail.posterminal/js/components/modalreceiptproperties.js
@@ -1,6 +1,6 @@
/*
************************************************************************************
- * Copyright (C) 2013-2016 Openbravo S.L.U.
+ * Copyright (C) 2013-2017 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.
@@ -154,7 +154,7 @@
this.loadValue(att);
}
}
- if (!_.isNull(bp)) {
+ if (!_.isNull(bp) && diff.bp) {
criteria.bpartner = bp.get('id');
if (OB.MobileApp.model.hasPermission('OBPOS_remote.customer', true)) {
var bPartnerId = {
diff --git a/web/org.openbravo.retail.posterminal/js/model/order.js b/web/org.openbravo.retail.posterminal/js/model/order.js
--- a/web/org.openbravo.retail.posterminal/js/model/order.js
+++ b/web/org.openbravo.retail.posterminal/js/model/order.js
@@ -1,6 +1,6 @@
/*
************************************************************************************
- * Copyright (C) 2013-2016 Openbravo S.L.U.
+ * Copyright (C) 2013-2017 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.
@@ -1025,9 +1025,6 @@
this.set('replacedorder_documentNo', _order.get('replacedorder_documentNo'));
}
- if (_order.get('replacedorder_documentNo')) {
- this.set('replacedorder_documentNo', _order.get('replacedorder_documentNo'));
- }
if (_order.get('replacedorder')) {
this.set('replacedorder', _order.get('replacedorder'));
}
posterminal_35025_2.diff [^] (2,668 bytes) 2017-02-01 12:36 [Show Content] [Hide Content]diff --git a/web/org.openbravo.retail.posterminal/js/components/modalreceiptproperties.js b/web/org.openbravo.retail.posterminal/js/components/modalreceiptproperties.js
--- a/web/org.openbravo.retail.posterminal/js/components/modalreceiptproperties.js
+++ b/web/org.openbravo.retail.posterminal/js/components/modalreceiptproperties.js
@@ -140,6 +140,16 @@
}
}
},
+ executeOnShow: function () {
+ var bp = this.model.get('bp');
+ if (bp.get('locId') === bp.get('shipLocId')) {
+ this.$.bodyContent.$.attributes.$.line_addressshipbutton.hide();
+ this.$.bodyContent.$.attributes.$.line_addressbillbutton.$.labelLine.setContent(OB.I18N.getLabel('OBPOS_LblAddress'));
+ } else {
+ this.$.bodyContent.$.attributes.$.line_addressshipbutton.show();
+ this.$.bodyContent.$.attributes.$.line_addressbillbutton.$.labelLine.setContent(OB.I18N.getLabel('OBPOS_LblBillAddr'));
+ }
+ },
init: function (model) {
var me = this,
criteria = {};
@@ -148,36 +158,12 @@
this.model = model.get('order');
this.model.on('change', function () {
var diff = this.model.changedAttributes(),
- att, bp = this.model.get('bp');
+ att;
for (att in diff) {
if (diff.hasOwnProperty(att)) {
this.loadValue(att);
}
}
- if (!_.isNull(bp) && diff.bp) {
- criteria.bpartner = bp.get('id');
- if (OB.MobileApp.model.hasPermission('OBPOS_remote.customer', true)) {
- var bPartnerId = {
- columns: ['bpartner'],
- operator: 'equals',
- value: bp.get('id'),
- isId: true
- };
- var remoteCriteria = [bPartnerId];
- criteria.remoteFilters = remoteCriteria;
- }
- OB.Dal.find(OB.Model.BPLocation, criteria, function (dataBps) {
- if (dataBps && dataBps.length === 1 && !_.isUndefined(me.$.bodyContent) && (dataBps.models[0].get('isBillTo') && dataBps.models[0].get('isShipTo'))) {
- me.$.bodyContent.$.attributes.$.line_addressshipbutton.hide();
- me.$.bodyContent.$.attributes.$.line_addressbillbutton.$.labelLine.setContent(OB.I18N.getLabel('OBPOS_LblAddress'));
- } else if (!_.isUndefined(me.$.bodyContent)) {
- me.$.bodyContent.$.attributes.$.line_addressshipbutton.show();
- me.$.bodyContent.$.attributes.$.line_addressbillbutton.$.labelLine.setContent(OB.I18N.getLabel('OBPOS_LblBillAddr'));
- }
- }, function (tx, error) {
- OB.UTIL.showError("OBDAL error: " + error);
- });
- }
}, this);
this.model.on('paymentAccepted', function () {
posterminal_35025_3.diff [^] (10,614 bytes) 2017-02-01 18:00 [Show Content] [Hide Content]diff --git a/web/org.openbravo.retail.posterminal/js/components/bplocation.js b/web/org.openbravo.retail.posterminal/js/components/bplocation.js
--- a/web/org.openbravo.retail.posterminal/js/components/bplocation.js
+++ b/web/org.openbravo.retail.posterminal/js/components/bplocation.js
@@ -1,6 +1,6 @@
/*
************************************************************************************
- * Copyright (C) 2012-2016 Openbravo S.L.U.
+ * Copyright (C) 2012-2017 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.
@@ -122,31 +122,38 @@
buttonShowing: function (bp) {
var criteria = {},
me = this;
+
+ function successLocations(dataBps) {
+ if (dataBps && dataBps.length > 1) {
+ me.changeStyle(true);
+ } else if (dataBps && dataBps.models && _.isArray(dataBps.models) && dataBps.models[0] && ((dataBps.models[0].get('isBillTo') && !dataBps.models[0].get('isShipTo')) || (!dataBps.models[0].get('isBillTo') && dataBps.models[0].get('isShipTo')))) {
+ me.changeStyle(true);
+ } else {
+ me.changeStyle(false);
+ }
+ }
+
if (!bp.get('shipLocId') && !bp.get('locId')) {
me.changeStyle(false);
} else {
- criteria.bpartner = bp.get('id');
- if (OB.MobileApp.model.hasPermission('OBPOS_remote.customer', true)) {
- var bPartnerId = {
- columns: ['bpartner'],
- operator: 'equals',
- value: bp.get('id'),
- isId: true
- };
- var remoteCriteria = [bPartnerId];
- criteria.remoteFilters = remoteCriteria;
+ if (bp.get('id') === OB.MobileApp.model.get('businesspartner')) {
+ successLocations(OB.MobileApp.model.get('businessPartner').locations);
+ } else {
+ criteria.bpartner = bp.get('id');
+ if (OB.MobileApp.model.hasPermission('OBPOS_remote.customer', true)) {
+ var bPartnerId = {
+ columns: ['bpartner'],
+ operator: 'equals',
+ value: bp.get('id'),
+ isId: true
+ };
+ var remoteCriteria = [bPartnerId];
+ criteria.remoteFilters = remoteCriteria;
+ }
+ OB.Dal.find(OB.Model.BPLocation, criteria, successLocations, function (tx, error) {
+ OB.UTIL.showError("OBDAL error: " + error);
+ });
}
- OB.Dal.find(OB.Model.BPLocation, criteria, function (dataBps) {
- if (dataBps && dataBps.length > 1) {
- me.changeStyle(true);
- } else if (dataBps && dataBps.models && _.isArray(dataBps.models) && dataBps.models[0] && ((dataBps.models[0].get('isBillTo') && !dataBps.models[0].get('isShipTo')) || (!dataBps.models[0].get('isBillTo') && dataBps.models[0].get('isShipTo')))) {
- me.changeStyle(true);
- } else {
- me.changeStyle(false);
- }
- }, function (tx, error) {
- OB.UTIL.showError("OBDAL error: " + error);
- });
}
},
tap: function () {
diff --git a/web/org.openbravo.retail.posterminal/js/components/businesspartner_selector.js b/web/org.openbravo.retail.posterminal/js/components/businesspartner_selector.js
--- a/web/org.openbravo.retail.posterminal/js/components/businesspartner_selector.js
+++ b/web/org.openbravo.retail.posterminal/js/components/businesspartner_selector.js
@@ -698,32 +698,10 @@
if (shipping && billing) {
this.setBPLocation(bpartner, shipping, billing);
} else {
- var criteria = {
- bpartner: {
- operator: OB.Dal.EQ,
- value: bpartner.get('bpartnerId')
- }
- };
- if (OB.MobileApp.model.hasPermission('OBPOS_remote.customer', true)) {
- var filterBpartnerId = {
- columns: ['bpartner'],
- operator: OB.Dal.EQ,
- value: bpartner.get('bpartnerId'),
- isId: true
- };
- criteria.remoteFilters = [filterBpartnerId];
- }
- OB.Dal.find(OB.Model.BPLocation, criteria, function (collection) {
- if (!billing) {
- billing = _.find(collection.models, function (loc) {
- return loc.get('isBillTo');
- });
- }
- if (!shipping) {
- shipping = _.find(collection.models, function (loc) {
- return loc.get('isShipTo');
- });
- }
+ var bp = new OB.Model.BusinessPartner({
+ id: bpartner.get('bpartnerId')
+ });
+ bp.loadBPLocations(shipping, billing, function (shipping, billing) {
me.setBPLocation(bpartner, shipping, billing);
});
}
@@ -741,27 +719,7 @@
}
var me = this;
OB.Dal.get(OB.Model.BusinessPartner, bpartner.get('bpartnerId'), function (bp) {
- if (shipping) {
- bp.set('shipLocId', shipping.get('id'));
- bp.set('shipLocName', shipping.get('name'));
- bp.set('shipCityName', shipping.get('cityName'));
- bp.set('shipPostalCode', shipping.get('postalCode'));
- } else {
- bp.set('shipLocId', null);
- bp.set('shipLocName', null);
- bp.set('shipCityName', null);
- bp.set('shipPostalCode', null);
- }
- if (billing) {
- bp.set("locId", billing.get("id"));
- bp.set("locName", billing.get("name"));
- } else {
- bp.set("locId", null);
- bp.set("locName", null);
- }
- if (OB.MobileApp.model.hasPermission('OBPOS_remote.customer', true)) {
- bp.set('locationModel', shipping);
- }
+ bp.setBPLocations(shipping, billing);
if (me.target.startsWith('filterSelectorButton_')) {
me.doChangeFilterSelector({
diff --git a/web/org.openbravo.retail.posterminal/js/model/businesspartner.js b/web/org.openbravo.retail.posterminal/js/model/businesspartner.js
--- a/web/org.openbravo.retail.posterminal/js/model/businesspartner.js
+++ b/web/org.openbravo.retail.posterminal/js/model/businesspartner.js
@@ -1,6 +1,6 @@
/*
************************************************************************************
- * Copyright (C) 2012-2016 Openbravo S.L.U.
+ * Copyright (C) 2012-2017 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.
@@ -198,6 +198,59 @@
},
serializeToJSON: function () {
return JSON.parse(JSON.stringify(this.toJSON()));
+ },
+ loadBPLocations: function (shipping, billing, callback) {
+ var criteria = {
+ bpartner: {
+ operator: OB.Dal.EQ,
+ value: this.get('id')
+ }
+ };
+ if (OB.MobileApp.model.hasPermission('OBPOS_remote.customer', true)) {
+ var filterBpartnerId = {
+ columns: ['bpartner'],
+ operator: OB.Dal.EQ,
+ value: this.get('id'),
+ isId: true
+ };
+ criteria.remoteFilters = [filterBpartnerId];
+ }
+ OB.Dal.find(OB.Model.BPLocation, criteria, function (collection) {
+ if (!billing) {
+ billing = _.find(collection.models, function (loc) {
+ return loc.get('isBillTo');
+ });
+ }
+ if (!shipping) {
+ shipping = _.find(collection.models, function (loc) {
+ return loc.get('isShipTo');
+ });
+ }
+ callback(shipping, billing, collection.models);
+ });
+ },
+ setBPLocations: function (shipping, billing) {
+ if (shipping) {
+ this.set('shipLocId', shipping.get('id'));
+ this.set('shipLocName', shipping.get('name'));
+ this.set('shipCityName', shipping.get('cityName'));
+ this.set('shipPostalCode', shipping.get('postalCode'));
+ } else {
+ this.set('shipLocId', null);
+ this.set('shipLocName', null);
+ this.set('shipCityName', null);
+ this.set('shipPostalCode', null);
+ }
+ if (billing) {
+ this.set("locId", billing.get("id"));
+ this.set("locName", billing.get("name"));
+ } else {
+ this.set("locId", null);
+ this.set("locName", null);
+ }
+ if (OB.MobileApp.model.hasPermission('OBPOS_remote.customer', true)) {
+ this.set('locationModel', shipping);
+ }
}
});
diff --git a/web/org.openbravo.retail.posterminal/js/pointofsale/model/pointofsale-model.js b/web/org.openbravo.retail.posterminal/js/pointofsale/model/pointofsale-model.js
--- a/web/org.openbravo.retail.posterminal/js/pointofsale/model/pointofsale-model.js
+++ b/web/org.openbravo.retail.posterminal/js/pointofsale/model/pointofsale-model.js
@@ -935,36 +935,15 @@
successCallbackBPLoc;
if (dataBps) {
- successCallbackBPLoc = function (bpLoc) {
- if (bpLoc.get('isBillTo')) {
- dataBps.set('locId', bpLoc.get('id'));
- dataBps.set('locName', bpLoc.get('name'));
- } else {
- dataBps.set('locId', null);
- dataBps.set('locName', null);
- }
- if (bpLoc.get('isShipTo')) {
- dataBps.set('shipLocId', bpLoc.get('id'));
- dataBps.set('shipLocName', bpLoc.get('name'));
- dataBps.set('shipRegionId', bpLoc.get('regionId'));
- dataBps.set('shipCountryId', bpLoc.get('countryId'));
- } else {
- dataBps.set('shipLocId', null);
- dataBps.set('shipLocName', null);
- dataBps.set('shipRegionId', null);
- dataBps.set('shipCountryId', null);
- }
- dataBps.set('cityName', bpLoc.get('cityName'));
- dataBps.set('countryName', bpLoc.get('countryName'));
- dataBps.set('postalCode', bpLoc.get('postalCode'));
- dataBps.set('locationModel', bpLoc);
+ dataBps.loadBPLocations(null, null, function (shipping, billing, locations) {
+ dataBps.setBPLocations(shipping, billing);
+ dataBps.set('locations', locations);
OB.MobileApp.model.set('businessPartner', dataBps);
OB.Dal.save(dataBps, function () {}, function () {
OB.error(arguments);
});
me.loadUnpaidOrders(callback);
- };
- OB.Dal.get(OB.Model.BPLocation, partnerAddressId, successCallbackBPLoc, errorCallback, errorCallback);
+ });
}
}
OB.Dal.get(OB.Model.BusinessPartner, OB.MobileApp.model.get('businesspartner'), successCallbackBPs, errorCallback, errorCallback);
posterminal_35025_4.diff [^] (696 bytes) 2017-02-02 13:21 [Show Content] [Hide Content]diff --git a/web/org.openbravo.retail.posterminal/js/model/businesspartner.js b/web/org.openbravo.retail.posterminal/js/model/businesspartner.js
--- a/web/org.openbravo.retail.posterminal/js/model/businesspartner.js
+++ b/web/org.openbravo.retail.posterminal/js/model/businesspartner.js
@@ -250,6 +250,11 @@
}
if (OB.MobileApp.model.hasPermission('OBPOS_remote.customer', true)) {
this.set('locationModel', shipping);
+ if (shipping !== null) {
+ this.set('cityName', shipping.get('cityName'));
+ this.set('countryName', shipping.get('countryName'));
+ this.set('postalCode', shipping.get('postalCode'));
+ }
}
}
});
posterminal_35025_5.diff [^] (2,482 bytes) 2017-02-03 09:59 [Show Content] [Hide Content]diff --git a/web/org.openbravo.retail.posterminal/js/components/businesspartner_selector.js b/web/org.openbravo.retail.posterminal/js/components/businesspartner_selector.js
--- a/web/org.openbravo.retail.posterminal/js/components/businesspartner_selector.js
+++ b/web/org.openbravo.retail.posterminal/js/components/businesspartner_selector.js
@@ -719,7 +719,7 @@
}
var me = this;
OB.Dal.get(OB.Model.BusinessPartner, bpartner.get('bpartnerId'), function (bp) {
- bp.setBPLocations(shipping, billing);
+ bp.setBPLocations(shipping, billing, OB.MobileApp.model.hasPermission('OBPOS_remote.customer', true));
if (me.target.startsWith('filterSelectorButton_')) {
me.doChangeFilterSelector({
diff --git a/web/org.openbravo.retail.posterminal/js/model/businesspartner.js b/web/org.openbravo.retail.posterminal/js/model/businesspartner.js
--- a/web/org.openbravo.retail.posterminal/js/model/businesspartner.js
+++ b/web/org.openbravo.retail.posterminal/js/model/businesspartner.js
@@ -229,7 +229,7 @@
callback(shipping, billing, collection.models);
});
},
- setBPLocations: function (shipping, billing) {
+ setBPLocations: function (shipping, billing, locationModel) {
if (shipping) {
this.set('shipLocId', shipping.get('id'));
this.set('shipLocName', shipping.get('name'));
@@ -248,7 +248,7 @@
this.set("locId", null);
this.set("locName", null);
}
- if (OB.MobileApp.model.hasPermission('OBPOS_remote.customer', true)) {
+ if (locationModel) {
this.set('locationModel', shipping);
if (shipping !== null) {
this.set('cityName', shipping.get('cityName'));
diff --git a/web/org.openbravo.retail.posterminal/js/pointofsale/model/pointofsale-model.js b/web/org.openbravo.retail.posterminal/js/pointofsale/model/pointofsale-model.js
--- a/web/org.openbravo.retail.posterminal/js/pointofsale/model/pointofsale-model.js
+++ b/web/org.openbravo.retail.posterminal/js/pointofsale/model/pointofsale-model.js
@@ -936,7 +936,7 @@
if (dataBps) {
dataBps.loadBPLocations(null, null, function (shipping, billing, locations) {
- dataBps.setBPLocations(shipping, billing);
+ dataBps.setBPLocations(shipping, billing, true);
dataBps.set('locations', locations);
OB.MobileApp.model.set('businessPartner', dataBps);
OB.Dal.save(dataBps, function () {}, function () {
posterminal_35025_6.diff [^] (2,814 bytes) 2017-02-27 14:36 [Show Content] [Hide Content]diff --git a/web/org.openbravo.retail.posterminal/js/components/bplocation.js b/web/org.openbravo.retail.posterminal/js/components/bplocation.js
--- a/web/org.openbravo.retail.posterminal/js/components/bplocation.js
+++ b/web/org.openbravo.retail.posterminal/js/components/bplocation.js
@@ -137,7 +137,7 @@
me.changeStyle(false);
} else {
if (bp.get('id') === OB.MobileApp.model.get('businesspartner')) {
- successLocations(OB.MobileApp.model.get('businessPartner').locations);
+ successLocations(OB.MobileApp.model.get('businessPartner').get('locations'));
} else {
criteria.bpartner = bp.get('id');
if (OB.MobileApp.model.hasPermission('OBPOS_remote.customer', true)) {
diff --git a/web/org.openbravo.retail.posterminal/js/data/datacustomeraddrsave.js b/web/org.openbravo.retail.posterminal/js/data/datacustomeraddrsave.js
--- a/web/org.openbravo.retail.posterminal/js/data/datacustomeraddrsave.js
+++ b/web/org.openbravo.retail.posterminal/js/data/datacustomeraddrsave.js
@@ -24,6 +24,24 @@
OB.DATA.executeCustomerAddressSave(this.customerAddr);
}, this);
+ OB.DATA.updateDefaultCustomerLocations = function (customerAddr) {
+ if (customerAddr.get('bpartner') === OB.MobileApp.model.get('businesspartner')) {
+ // Update default BP locations cache
+ var i, foundAddress = false,
+ locations = OB.MobileApp.model.get('businessPartner').get('locations');
+ for (i = 0; i < locations.length; i++) {
+ if (locations[i].get('id') === customerAddr.get('id')) {
+ locations[i] = customerAddr.clone();
+ foundAddress = true;
+ break;
+ }
+ }
+ if (!foundAddress) {
+ locations.push(customerAddr.clone());
+ }
+ }
+ };
+
OB.DATA.executeCustomerAddressSave = function (customerAddr, callback) {
var customerAddrList, customerAddrId = customerAddr.get('id'),
isNew = false,
@@ -55,6 +73,7 @@
}
me.receipt.trigger('change:bp', me.receipt);
bpLocToSave.set('isbeingprocessed', 'Y');
+ OB.DATA.updateDefaultCustomerLocations(customerAddr);
OB.Dal.save(bpLocToSave, function () {
bpLocToSave.set('json', JSON.stringify(customerAddr.serializeToJSON()));
var successCallback, errorCallback, List;
@@ -101,6 +120,7 @@
//save that the customer address is being processed by server
customerAddr.set('loaded', OB.I18N.normalizeDate(new Date()));
OB.Dal.save(customerAddr, function () {
+ OB.DATA.updateDefaultCustomerLocations(customerAddr);
me.receipt.trigger('change:bp', me.receipt);
if (isNew) {
customerAddr.set('posTerminal', OB.MobileApp.model.get('terminal').id);
|