Merge lp:~openerp-dev/openobject-addons/6.1-opw-580254-msh into lp:openobject-addons/6.1

Proposed by Mohammed Shekha(Open ERP)
Status: Needs review
Proposed branch: lp:~openerp-dev/openobject-addons/6.1-opw-580254-msh
Merge into: lp:openobject-addons/6.1
Diff against target: 41 lines (+13/-10)
1 file modified
point_of_sale/static/src/js/pos.js (+13/-10)
To merge this branch: bzr merge lp:~openerp-dev/openobject-addons/6.1-opw-580254-msh
Reviewer Review Type Date Requested Status
OpenERP Core Team Pending
Review via email:

Description of the change


Fixed the issue in POS, error comes 'result[0] is undefined' or 'unexpected token u' or 'JSON.parse: unexpected character'.

Demo :- It can be easily faced with demo data in multi company environment, if you have miss-configured, there is record rule ['|',('company_id','=',False),('company_id','child_of',[])] on, so if your shop configuration is not proper then POS front end will raise above issue.

1. Settings => Users => Users => Multi companies is enabled.
2. Create shop which breaks above record rule.

Now go to POS front end, it will raise an error of 'result[0] is undefined' first time and then each time will raise 'unexpected token u' or 'JSON.parse: unexpected character'.

Expected :- No doubt there is wrong configuration but Web-Client should not throw error due to wrong configuration.

Reason :- Due to wrong configuration record rule is not satisfied so when Open POS front end it will tried to serach and read and will not get any shop so first time it will raise 'result[0] is undefined' while try to set company_id, then each time when you open POS front end it will raise JSON.parse error because no shop found in result from search_read so 'undefined' is set in Store for shop.


To post a comment you must log in.

Unmerged revisions

7033. By Mohammed Shekha(Open ERP)

[FIX]Fixed the issue of POS break in multi company environment, when there is misconfiguration, as well as pos order line is not going to save because name is missing in pos order line.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'point_of_sale/static/src/js/pos.js'
2--- point_of_sale/static/src/js/pos.js 2012-05-05 16:09:02 +0000
3+++ point_of_sale/static/src/js/pos.js 2012-10-18 13:21:38 +0000
4@@ -89,17 +89,19 @@
5 get_app_data: function() {
6 var self = this;
7 return $.when(new db.web.Model("").get_func("search_read")([]).pipe(function(result) {
8- self.set({'shop': result[0]});
9- var company_id = result[0]['company_id'][0];
10- return new db.web.Model("").get_func("read")(company_id, ['currency_id', 'name', 'phone']).pipe(function(result) {
11- self.set({'company': result});
12- var currency_id = result['currency_id'][0]
13- return new db.web.Model("res.currency").get_func("read")([currency_id],
14- ['symbol', 'position']).pipe(function(result) {
15- self.set({'currency': result[0]});
17+ if(result.length){
18+ self.set({'shop': result[0]});
19+ var company_id = result[0]['company_id'][0];
20+ return new db.web.Model("").get_func("read")(company_id, ['currency_id', 'name', 'phone']).pipe(function(result) {
21+ self.set({'company': result});
22+ var currency_id = result['currency_id'][0]
23+ return new db.web.Model("res.currency").get_func("read")([currency_id],
24+ ['symbol', 'position']).pipe(function(result) {
25+ self.set({'currency': result[0]});
27+ });
28 });
29- });
30+ }
31 }), new db.web.Model("res.users").get_func("read")(this.session.uid, ['name']).pipe(function(result) {
32 self.set({'user': result});
33 }));
34@@ -308,6 +310,7 @@
35 },
36 exportAsJSON: function() {
37 return {
38+ name: this.get('name'),
39 qty: this.get('quantity'),
40 price_unit: this.get('list_price'),
41 discount: this.get('discount'),