Odoo Help

2

0
3 Answers
2
Avatar
--deep--

Techno-Functional Associate with 7+ years of experience in Odoo (formerly known as OpenERP).

deep India
10/31/16, 1:45 AM

You can get the current url from Prams object as follows

base_url = self.env['ir.config_parameter'].sudo().get_param('web.base.url')


or you can fetch the details from self.environment



2 Comments
Prince Caspion United States
11/1/16, 8:19 AM

I've already tried this one but it just gives base url not complete url. i need complete url.

deep India
11/1/16, 9:12 AM

Then fetch the details from self.environment or http/request

1
Avatar

Shameem Babu @ iWesabe Saudi Arabia

--Shameem Babu @ iWesabe--
GLOBAL CREATIVE CONCEPTS TECH CO LTD
http://www.iwesabe.com
1598
| 6 3 9
KHOBAR, Saudi Arabia
--Shameem Babu @ iWesabe--

  

 iWesabe - ODOO ERP IMPLEMENTATION & CUSTOMIZATION SAUDI ARABIA.



For Queries : pks.shameem@gmail.com ,shameem@iwesabe.com

Activities     :    Youtube

                           Stackoverflow 

Experience

           iWesabe                                ◉

           Axon Communications        ❍

           Cybrosys Technologies        ❍


Shameem Babu @ iWesabe Saudi Arabia
10/31/16, 1:18 AM

Hi Prince, You try my way


Step1 : Create a javascript file and call a python function when URL changes

refer : https://www.odoo.com/forum/help-1/question/odoo-9-website-js-help-109603#answer-109604

Pass the current url in that function

Example

$(window).on('hashchange', function(e){
    ajax.jsonRpc("/action_set_current_url/", 'call', window.location.href)
});


Step2: In python function, Set the current url to session.

Example

from openerp import http
from openerp.http import request
class YourModel(http.Controller):
    @http.route(['/action_set_current_url/<string:url>'], type='json', auth="public")
    def set_current_url(self, url,**post):
        # CODE TO SET COOKIES
        request.session['my_current_url'] = url


Step3:

 Call the current url from your function

 Example

def your_function(self):
    # CODE TO GET URL
    current_url = request.session.get('my_current_url')


Note : my code is not tested

4 Comments
Prince Caspion United States
10/31/16, 1:40 AM

thanks for your answer and quick response. but the problem is my function is called in back end it is not dealing with any web/js action. I am not sure, can i get the current full path in the method which is called in button click.

GLOBAL CREATIVE CONCEPTS TECH CO LTD, Shameem Babu @ iWesabe Saudi Arabia
10/31/16, 1:47 AM

I have tried many times

https://www.odoo.com/forum/help-1/question/how-to-get-current-url-from-bowser-101333#answer-108714

I found this is only one solution

It is possible in backend

Link JS like this

<template id="assets_backend" name="im assets" inherit_id="web.assets_backend">

<xpath expr="." position="inside">

<script type="text/javascript" src="/path /to/file.js"></script>

</xpath>

</template>

Prince Caspion United States
10/31/16, 5:47 AM

thanks, i will check it.

GLOBAL CREATIVE CONCEPTS TECH CO LTD, Shameem Babu @ iWesabe Saudi Arabia
11/2/16, 2:33 AM

A small change in my answer. I told to write script when document is ready.

But you need to write when url changes

Ask a Question
Writer
Tags
Keep Informed
1 follower(s)
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