mirror of
https://gitlab.com/hibou-io/hibou-odoo/suite.git
synced 2025-01-20 12:37:31 +02:00
[IMP] auth_admin, [ADD] auth_admin_website: enable select website to get base url from company
H4905
This commit is contained in:
1
auth_admin_website/wizard/__init__.py
Normal file
1
auth_admin_website/wizard/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from . import portal_wizard
|
||||
20
auth_admin_website/wizard/portal_wizard.py
Executable file
20
auth_admin_website/wizard/portal_wizard.py
Executable file
@@ -0,0 +1,20 @@
|
||||
from odoo import fields, models
|
||||
from odoo.addons.auth_admin.models.res_users import admin_auth_generate_login
|
||||
|
||||
|
||||
class PortalWizardUser(models.TransientModel):
|
||||
_inherit = 'portal.wizard.user'
|
||||
|
||||
website_id = fields.Many2one('website', string='Website')
|
||||
|
||||
def admin_auth_generate_login(self):
|
||||
ir_model_access = self.env['ir.model.access']
|
||||
for row in self.filtered(lambda r: r.in_portal):
|
||||
user = row.partner_id.user_ids[0] if row.partner_id.user_ids else None
|
||||
if ir_model_access.check('res.partner', mode='unlink') and user:
|
||||
if row.website_id:
|
||||
base_url = row.website_id.get_base_url()
|
||||
else:
|
||||
base_url = None
|
||||
row.force_login_url = admin_auth_generate_login(self.env, user, base_url=base_url)
|
||||
self.filtered(lambda r: not r.in_portal).update({'force_login_url': ''})
|
||||
13
auth_admin_website/wizard/portal_wizard_views.xml
Normal file
13
auth_admin_website/wizard/portal_wizard_views.xml
Normal file
@@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<odoo>
|
||||
<record id="portal_wizard" model="ir.ui.view">
|
||||
<field name="name">Portal Access Management - Auth Admin Multi-Website</field>
|
||||
<field name="model">portal.wizard</field>
|
||||
<field name="inherit_id" ref="auth_admin.portal_wizard"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//field[@name='force_login_url']" position="before">
|
||||
<field name="website_id"/>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
</odoo>
|
||||
Reference in New Issue
Block a user