|View Issue Details|
|Type||Category||Severity||Reproducibility||Date Submitted||Last Update|
|defect||[Retail Modules] Web POS||major||always||2017-05-15 16:30||2017-05-19 11:16|
|Priority||high||Resolution||fixed||Fixed in Version|
|Status||resolved||Fix in branch||Fixed in SCM revision||40bd1098c958|
|OS Version||Database version||Ant version|
|Product Version||SCM revision|
|Review Assigned To|
|Regression introduced in release|
|Regression introduced by commit|
|Triggers an Emergency Pack||No|
The issue can be reproduced easily if the internet connection speed is slow, or if the OBPOS_PostCustomerSave hook includes several remote calls.
|Steps To Reproduce||Using standard retail sampledata (livebuilds).|
Login in backend.
Go to the Preference window and configure the following preferences:
*Enable Remote for Customer with value 'Y'
*Terminal Authentication enabled with value 'Y'
Go to the POS Terminal window, find the VBS-1 terminal and define the Terminal Key Identifier as VBS1
Login in web pos, terminal VBS-1. The Terminal Authentication window will be shown.
Enter the requested values.
Once the application has logged in, open the browser console, go to the Network tab and enable a slow throttling (i.e. GPRS, 50kb/s).
In web pos, open the customer selector popup and edit the VBS Customer record.
Click on Save.
A "SyntaxError: Unexpected token o in JSON at position 1" error will be raised and the customer edition won't be saved.
|Proposed Solution||The functions defined on the datacustomersave.js file are in charge of saving and synchronizing modifications done to customers from webpos. The functions on this file use a reference to OB.Model.ChangedBusinessPartners, which is the model used to synchronize changes to business partners.|
The reference to that object, bpToSave, is used on different parts of the code, which asynchronously access and modify the object.
Especifically, the OBPOS_PostCustomerSave hook is called twice using the same object ( and ).
The callback of the first hook saves the model, then changes the json property of the object (assigning a js object instead of a string, corrupting the object and later causing the SyntaxError) and finally it tries to synchronize the customer.
The callback of the second hook saves the same object again, and finally tries to synchronize the object again. If the connection speed is slow, the first hook finishes before reaching this point, so the 2nd synchronization is done using a corrupt BP object):
This code should be refactored to call the hook only once, regardless of which flow is executed (create/update, either in remote or local mode).
Also if the same object is going to be used across the code, the asynchrony should be controlled using callbacks, to ensure that the code is always executed in the same order.
 https://code.openbravo.com/erp/pmods/org.openbravo.retail.posterminal/file/12a71cc328da/web/org.openbravo.retail.posterminal/js/data/datacustomersave.js#l121 [^]
 https://code.openbravo.com/erp/pmods/org.openbravo.retail.posterminal/file/12a71cc328da/web/org.openbravo.retail.posterminal/js/data/datacustomersave.js#l197 [^]
|Tags||No tags attached.|
Author: Miguel de Juana <miguel.dejuana <at> openbravo.com>
Date: Fri May 19 09:14:50 2017 +0200
URL: http://code.openbravo.com/erp/pmods/org.openbravo.retail.posterminal/rev/40bd1098c95802ebaebb1a09416604a056beebc9 [^]
- Stringify json object to set it to the bp to save
- Execute OBPOS_PostCustomerSave just once
|2017-05-15 16:30||aaroncalero||New Issue|
|2017-05-15 16:30||aaroncalero||Assigned To||=> Retail|
|2017-05-15 16:30||aaroncalero||Triggers an Emergency Pack||=> No|
|2017-05-16 16:28||migueldejuana||Relationship added||related to 0033926|
|2017-05-16 16:28||migueldejuana||Relationship added||related to 0034023|
|2017-05-19 09:15||hgbot||Note Added: 0096670|
|2017-05-19 09:15||hgbot||Status||new => resolved|
|2017-05-19 09:15||hgbot||Resolution||open => fixed|
|2017-05-19 09:15||hgbot||Fixed in SCM revision||=> http://code.openbravo.com/erp/pmods/org.openbravo.retail.posterminal/rev/40bd1098c95802ebaebb1a09416604a056beebc9 [^]|
|2017-05-19 11:16||migueldejuana||Relationship added||related to 0036051|
|Copyright © 2000 - 2009 MantisBT Group|