[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#77705

X-original-commit: d094d76354d6f46db3dc7f8e716b5f778ca26569
Signed-off-by: agr-odoo <agr-odoo@users.noreply.github.com>
This commit is contained in:
Andrea Grazioso (agr-odoo)
2021-10-04 14:12:26 +00:00
parent 18e805d0e6
commit fe82ccc860
2 changed files with 9 additions and 1 deletions
+1 -1
View File
@@ -69,7 +69,7 @@ class LinkTracker(models.Model):
@api.depends('code')
def _compute_short_url(self):
for tracker in self:
tracker.short_url = urls.url_join(tracker.get_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:
@@ -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/')