mirror of
https://gitlab.com/hibou-io/hibou-odoo/suite.git
synced 2025-01-20 12:37:31 +02:00
[MIG] auth_admin: to Odoo 15.0
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
'name': 'Auth Admin',
|
||||
'author': 'Hibou Corp. <hello@hibou.io>',
|
||||
'category': 'Hidden',
|
||||
'version': '13.0.1.0.0',
|
||||
'version': '15.0.1.0.0',
|
||||
'description':
|
||||
"""
|
||||
Login as other user
|
||||
|
||||
@@ -33,7 +33,7 @@ class AuthAdmin(http.Controller):
|
||||
uid = http.request.session.authenticate(http.request.session.db, user.login, 'x')
|
||||
if uid is not False:
|
||||
http.request.params['login_success'] = True
|
||||
return http.redirect_with_hash('/my/home')
|
||||
return http.local_redirect('/my/home')
|
||||
return http.request.redirect('/my/home')
|
||||
return http.request.redirect('/my/home')
|
||||
except (exceptions.Warning, ) as e:
|
||||
return http.Response(e.message, status=400)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from odoo import api, fields, models
|
||||
from odoo import api, fields, models, _
|
||||
from ..models.res_users import admin_auth_generate_login
|
||||
|
||||
|
||||
@@ -24,8 +24,16 @@ class PortalWizardUser(models.TransientModel):
|
||||
|
||||
def admin_auth_generate_login(self):
|
||||
ir_model_access = self.env['ir.model.access']
|
||||
for row in self.filtered(lambda r: r.in_portal):
|
||||
for row in self.filtered(lambda r: r.is_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:
|
||||
row.force_login_url = admin_auth_generate_login(self.env, user)
|
||||
self.filtered(lambda r: not r.in_portal).update({'force_login_url': ''})
|
||||
self.filtered(lambda r: not r.is_portal).update({'force_login_url': ''})
|
||||
return {
|
||||
'name': _('Portal Access Management'),
|
||||
'type': 'ir.actions.act_window',
|
||||
'view_mode': 'form',
|
||||
'res_model': 'portal.wizard',
|
||||
'res_id': self.wizard_id.id,
|
||||
'target': 'new',
|
||||
}
|
||||
|
||||
@@ -6,10 +6,10 @@
|
||||
<field name="model">portal.wizard</field>
|
||||
<field name="inherit_id" ref="portal.wizard_view"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//field[@name='in_portal']" position="after">
|
||||
<xpath expr="//field[@name='is_portal']" position="after">
|
||||
<field name="force_login_url"/>
|
||||
</xpath>
|
||||
<xpath expr="//button[last()]" position="after">
|
||||
<xpath expr="//tree/button[last()]" position="after">
|
||||
<button string="Generate Login URL" type="object" name="admin_auth_generate_login" class="btn-primary" />
|
||||
</xpath>
|
||||
</field>
|
||||
|
||||
Reference in New Issue
Block a user