Skip to content
Snippets Groups Projects
Commit f4735436 authored by Andrea Grazioso (agr-odoo)'s avatar Andrea Grazioso (agr-odoo)
Browse files

[FIX] link_tracker,website_links: use specific site url


- Create 3 websites and set a website domain for each
- Install the website_links module
- Go to Website > Configuration > Settings
- Select the website 3
- Go to website
- Menu Promote > Link tracking

The URL field uses the domain you are logged into the database
rather than the domain of the active website

The expected behavior is:
With an ICP set to URL1, a website 1 set to URL2 and a website 2 set to
URL3, going to the link tracker website page from URL3 but with website
1 selected should:

Show the current website domain as placeholder of the input -> URL2
Create link for that current website the user selected -> URL2

opw-2638494

closes odoo/odoo#76551

Signed-off-by: default avataragr-odoo <agr-odoo@users.noreply.github.com>
parent f7461a66
No related branches found
No related tags found
No related merge requests found
......@@ -68,12 +68,12 @@ class LinkTracker(models.Model):
@api.depends('code')
def _compute_short_url(self):
for tracker in self:
base_url = self.env['ir.config_parameter'].sudo().get_param('web.base.url')
tracker.short_url = urls.url_join(base_url, '/r/%(code)s' % {'code': tracker.code})
tracker.short_url = urls.url_join(tracker.short_url_host, '%(code)s' % {'code': tracker.code})
def _compute_short_url_host(self):
for tracker in self:
tracker.short_url_host = self.env['ir.config_parameter'].sudo().get_param('web.base.url') + '/r/'
base_url = tracker.get_base_url()
tracker.short_url_host = urls.url_join(base_url, '/r/')
def _compute_code(self):
for tracker in self:
......
......@@ -3,6 +3,9 @@
from odoo import models, _
from werkzeug import urls
class LinkTracker(models.Model):
_inherit = ['link.tracker']
......@@ -13,3 +16,8 @@ class LinkTracker(models.Model):
'url': '%s+' % (self.short_url),
'target': 'new',
}
def _compute_short_url_host(self):
for tracker in self:
base_url = self.env['website'].get_current_website().get_base_url()
tracker.short_url_host = urls.url_join(base_url, '/r/')
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment