Mohammed Shekha(Open ERP) has proposed merging 
lp:~openerp-dev/openobject-addons/6.1-opw-580254-msh into 
lp:openobject-addons/6.1.

Requested reviews:
  OpenERP Core Team (openerp)

For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-addons/6.1-opw-580254-msh/+merge/130342

Hello,

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 sale.shop, there is record rule 
['|',('company_id','=',False),('company_id','child_of',[user.company_id.id])] 
on sale.shop, 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 sale.shop 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.

Thanks.
-- 
https://code.launchpad.net/~openerp-dev/openobject-addons/6.1-opw-580254-msh/+merge/130342
Your team OpenERP R&D Team is subscribed to branch 
lp:~openerp-dev/openobject-addons/6.1-opw-580254-msh.
=== modified file 'point_of_sale/static/src/js/pos.js'
--- point_of_sale/static/src/js/pos.js	2012-05-05 16:09:02 +0000
+++ point_of_sale/static/src/js/pos.js	2012-10-18 13:21:38 +0000
@@ -89,17 +89,19 @@
         get_app_data: function() {
             var self = this;
             return $.when(new db.web.Model("sale.shop").get_func("search_read")([]).pipe(function(result) {
-                self.set({'shop': result[0]});
-                var company_id = result[0]['company_id'][0];
-                return new db.web.Model("res.company").get_func("read")(company_id, ['currency_id', 'name', 'phone']).pipe(function(result) {
-                    self.set({'company': result});
-                    var currency_id = result['currency_id'][0]
-                    return new db.web.Model("res.currency").get_func("read")([currency_id],
-                            ['symbol', 'position']).pipe(function(result) {
-                        self.set({'currency': result[0]});
-                        
+                if(result.length){
+                    self.set({'shop': result[0]});
+                    var company_id = result[0]['company_id'][0];
+                    return new db.web.Model("res.company").get_func("read")(company_id, ['currency_id', 'name', 'phone']).pipe(function(result) {
+                        self.set({'company': result});
+                        var currency_id = result['currency_id'][0]
+                        return new db.web.Model("res.currency").get_func("read")([currency_id],
+                                ['symbol', 'position']).pipe(function(result) {
+                            self.set({'currency': result[0]});
+                            
+                        });
                     });
-                });
+                }
             }), new db.web.Model("res.users").get_func("read")(this.session.uid, ['name']).pipe(function(result) {
                 self.set({'user': result});
             }));
@@ -308,6 +310,7 @@
         },
         exportAsJSON: function() {
             return {
+                name: this.get('name'),
                 qty: this.get('quantity'),
                 price_unit: this.get('list_price'),
                 discount: this.get('discount'),

_______________________________________________
Mailing list: https://launchpad.net/~openerp-dev-gtk
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~openerp-dev-gtk
More help   : https://help.launchpad.net/ListHelp

Reply via email to