mirror of
https://gitlab.com/hibou-io/hibou-odoo/suite.git
synced 2025-01-20 12:37:31 +02:00
[IMP] auth_admin: add new wizard and use CopyClipboardChar widget
H13350
This commit is contained in:
@@ -23,6 +23,8 @@ Out of the box, only allows you to generate a login for an 'External User', e.g.
|
|||||||
'auto_install': False,
|
'auto_install': False,
|
||||||
'data': [
|
'data': [
|
||||||
'views/res_users.xml',
|
'views/res_users.xml',
|
||||||
|
'security/ir.model.access.csv',
|
||||||
'wizard/portal_wizard_views.xml',
|
'wizard/portal_wizard_views.xml',
|
||||||
|
'wizard/res_users_wizard_views.xml',
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
from odoo import models, api, exceptions
|
from odoo import models, api, exceptions, fields, _
|
||||||
from odoo.http import request
|
from odoo.http import request
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from time import mktime
|
from time import mktime
|
||||||
@@ -77,7 +77,17 @@ class ResUsers(models.Model):
|
|||||||
|
|
||||||
login_url = admin_auth_generate_login(self.env, self)
|
login_url = admin_auth_generate_login(self.env, self)
|
||||||
if login_url:
|
if login_url:
|
||||||
raise exceptions.UserError(login_url)
|
wizard = self.env['res.users.wizard'].create({
|
||||||
|
'force_login_url': login_url,
|
||||||
|
})
|
||||||
|
return {
|
||||||
|
'name': _('Generate Login URL'),
|
||||||
|
'type': 'ir.actions.act_window',
|
||||||
|
'view_mode': 'form',
|
||||||
|
'res_model': 'res.users.wizard',
|
||||||
|
'res_id': wizard.id,
|
||||||
|
'target': 'new',
|
||||||
|
}
|
||||||
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@@ -90,3 +100,9 @@ class ResUsers(models.Model):
|
|||||||
str(request.session.uid) + ' original user id: ' + str(request.session.auth_admin))
|
str(request.session.uid) + ' original user id: ' + str(request.session.auth_admin))
|
||||||
else:
|
else:
|
||||||
raise
|
raise
|
||||||
|
|
||||||
|
|
||||||
|
class ResUsersWizard(models.TransientModel):
|
||||||
|
_name = 'res.users.wizard'
|
||||||
|
|
||||||
|
force_login_url = fields.Char(string='Force Login URL')
|
||||||
|
|||||||
2
auth_admin/security/ir.model.access.csv
Normal file
2
auth_admin/security/ir.model.access.csv
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
|
||||||
|
access_auth_admin,access.res.users.wizard,model_res_users_wizard,base.group_user,1,1,1,1
|
||||||
|
@@ -1,5 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" ?>
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
<odoo>
|
<odoo>
|
||||||
|
|
||||||
<record id="auth_admin_view_users_tree" model="ir.ui.view">
|
<record id="auth_admin_view_users_tree" model="ir.ui.view">
|
||||||
<field name="name">auth_admin.res.users.tree</field>
|
<field name="name">auth_admin.res.users.tree</field>
|
||||||
<field name="model">res.users</field>
|
<field name="model">res.users</field>
|
||||||
@@ -11,4 +12,5 @@
|
|||||||
</xpath>
|
</xpath>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
</odoo>
|
|
||||||
|
</odoo>
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
<field name="inherit_id" ref="portal.wizard_view"/>
|
<field name="inherit_id" ref="portal.wizard_view"/>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<xpath expr="//field[@name='is_portal']" position="after">
|
<xpath expr="//field[@name='is_portal']" position="after">
|
||||||
<field name="force_login_url"/>
|
<field name="force_login_url" widget="CopyClipboardChar"/>
|
||||||
</xpath>
|
</xpath>
|
||||||
<xpath expr="//tree/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" />
|
<button string="Generate Login URL" type="object" name="admin_auth_generate_login" class="btn-primary" />
|
||||||
@@ -15,4 +15,4 @@
|
|||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
</odoo>
|
</odoo>
|
||||||
|
|||||||
18
auth_admin/wizard/res_users_wizard_views.xml
Normal file
18
auth_admin/wizard/res_users_wizard_views.xml
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<odoo>
|
||||||
|
|
||||||
|
<record id="res_users_wizard" model="ir.ui.view">
|
||||||
|
<field name="name">Generate Login URL</field>
|
||||||
|
<field name="model">res.users.wizard</field>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<form string="Generate Login URL">
|
||||||
|
<sheet>
|
||||||
|
<group>
|
||||||
|
<field name="force_login_url" widget="CopyClipboardChar"/>
|
||||||
|
</group>
|
||||||
|
</sheet>
|
||||||
|
</form>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
</odoo>
|
||||||
Reference in New Issue
Block a user