[IMP] portal: add portal.mixin for portal access records
This mixin holds the replacement for website_published.mixin website_url field. This field is called portal_url to avoid confusion with the website and enforce the new portal use. It also contains get_share_url method that will be used to generate the URL to use in emails or various communication for customers.
This commit is contained in:
@@ -2,4 +2,5 @@
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from . import controllers
|
||||
from . import models
|
||||
from . import wizard
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from . import portal_mixin
|
||||
@@ -0,0 +1,32 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from werkzeug.urls import url_encode
|
||||
|
||||
from odoo import api, fields, models
|
||||
|
||||
|
||||
class PortalMixin(models.AbstractModel):
|
||||
_name = "portal.mixin"
|
||||
|
||||
portal_url = fields.Char(
|
||||
'Portal Access URL', compute='_compute_portal_url',
|
||||
help='Customer Portal URL')
|
||||
|
||||
@api.multi
|
||||
def _compute_portal_url(self):
|
||||
for record in self:
|
||||
record.portal_url = '#'
|
||||
|
||||
def get_share_url(self):
|
||||
self.ensure_one()
|
||||
params = {
|
||||
'model': self._name,
|
||||
'res_id': self.id,
|
||||
}
|
||||
if hasattr(self, 'access_token') and self.access_token:
|
||||
params['access_token'] = self.access_token
|
||||
if hasattr(self, 'partner_id') and self.partner_id:
|
||||
params.update(self.partner_id.signup_get_auth_param()[self.partner_id.id])
|
||||
|
||||
return '/mail/view?' + url_encode(params)
|
||||
Reference in New Issue
Block a user