Anonymous | Login
News | My View | View Issues | Roadmap | Summary

View Issue DetailsJump to Notes ] Issue History ] Print ]
TypeCategorySeverityReproducibilityDate SubmittedLast Update
defect[Retail Modules] Web POSmajoralways2017-05-15 16:302017-05-29 13:59
ReporteraaroncaleroView Statuspublic 
Assigned Tomigueldejuana 
PriorityhighResolutionfixedFixed in VersionRR17Q3
StatusclosedFix in branchFixed in SCM revision40bd1098c958
ProjectionnoneETAnoneTarget Version
OSAnyDatabaseAnyJava version
OS VersionDatabase versionAnt version
Product VersionSCM revision 
Review Assigned Toguilleaer
Regression level
Regression date
Regression introduced in release
Regression introduced by commit
Triggers an Emergency PackNo

0035998: Javascript error editing the current customer on remote mode, using Terminal Authentication

DescriptionWhen the Remote mode for customers is configured together with the Terminal Authentication preference, a javascript error might raise while trying to save changes done to the customer currently assigned to the receipt.
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 ReproduceUsing 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 SolutionThe 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 ([1] and [2]).
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.

[1] [^]
[2] [^]
TagsNo tags attached.
Attached Files

- Relationships Relation Graph ] Dependency Graph ]
related to defect 0033926 closedmtaal [STORE SERVER] Business partners are not updated when editing them in Web POS. 
related to defect 0034023RR16Q4 closedmtaal JSON error unexpected token in remote BP data when saving address through customer 
related to defect 0036051 newRetail datacustomersave.js executes twice OBPOS_PostCustomerSave 

-  Notes
hgbot (developer)
2017-05-19 09:15

Repository: erp/pmods/org.openbravo.retail.posterminal
Changeset: 40bd1098c95802ebaebb1a09416604a056beebc9
Author: Miguel de Juana <miguel.dejuana <at>>
Date: Fri May 19 09:14:50 2017 +0200
URL: [^]

Fixed issue 0035998: Javascript error editing the current customer on remote mode, using Terminal Authentication

- Stringify json object to set it to the bp to save
- Execute OBPOS_PostCustomerSave just once

M web/org.openbravo.retail.posterminal/js/data/datacustomersave.js

- Issue History
Date Modified Username Field Change
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 Checkin
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 => [^]
2017-05-19 11:16 migueldejuana Relationship added related to 0036051
2017-05-25 12:13 marvintm Assigned To Retail => migueldejuana
2017-05-29 13:59 guilleaer Review Assigned To => guilleaer
2017-05-29 13:59 guilleaer Status resolved => closed
2017-05-29 13:59 guilleaer Fixed in Version => RR17Q3

Copyright © 2000 - 2009 MantisBT Group
Powered by Mantis Bugtracker