Odoo is the world's easiest all-in-one management software. It includes hundreds of business apps:
CRM | e-Commerce | Accounting | Inventory | PoS | Project management | MRP | etc.
i have a python function that returns a string that i will be using in a JS function (google maps)
i have the below python code
def tt_js_return_url(self): return self.latitude + "," + self.longitude
Do you have an idea of how to get the function return in the JS code?
You can call your python method through your .js file using .call method.
I assume, your class name is 'my.module', then you can call your method, using following way.
var MyModel = new Model('my.module')
// your code , in result you will get value returned by python method.
I am not sure that I understand you correctly. What i am imagining :
In your front end html site:
If that is true, please read https://www.odoo.com/documentation/8.0/howtos/web.html too know how to insert your js files when Odoo render the page, and call your tt_js_return_url as describled in Communication with the Odoo Server section.
After your call to server, you'll get long+lat, assign it to a global variable to make it available in your google_map.js.
Hope this helps.
I can think of 2 ways to do this:
If your html page is in a separated application from Odoo, you may write kind of webservice in Odoo and call it from your maps application.
Odoo Maps application
At odoo side, you should write a method in a controller like this:
@http.route(route='/get_vehicle_cordinates', auth='public') # consider authorization check
def get_vehicle_cordinate(self, **kwargs):
# And calculate cordinates to return
// Handle your long, lat value.
2. The second way, if your html page is a part of Odoo, you may put your map in a Odoo widget.
Define html code in a template, use call method (please read Communication with the Odoo Server which I mentioned above) to call tt_js_return_url and handle the result
About This Community
This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.Register
Odoo Training Center
Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.Test it now
|Asked: 3/8/16, 6:25 PM|
|Seen: 881 times|
|Last updated: 9/19/16, 3:56 AM|