Created
August 24, 2012 20:30
-
-
Save guerrerocarlos/3455296 to your computer and use it in GitHub Desktop.
get_app_data function of OpenERP
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
get_app_data: function() { | |
var self = this; | |
return $.when( | |
new db.web.Model("res.users").get_func("read")(this.session.uid, ['shop_id']).pipe(function(result) { | |
var shop_id = result['shop_id'][0]; | |
new db.web.Model("sale.shop").get_func("search_read")([['id','=',shop_id]],[]).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]}); | |
}); | |
}); | |
}); | |
}) | |
, | |
new db.web.Model("res.users").get_func("read")(this.session.uid, ['name']).pipe(function(result) { self.set({'user': result}); }) | |
); | |
}, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment