[IMP] base,auth_password_policy: add form view for changing password
Purpose: The form view is more intuitive then list view in case user wants to change the password only for one user. task - 3105178 closes odoo/odoo#109869 Signed-off-by: Kevin Baptiste <kba@odoo.com>
This commit is contained in:
@@ -19,4 +19,14 @@
|
|||||||
</xpath>
|
</xpath>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
<record id="change_password_user" model="ir.ui.view">
|
||||||
|
<field name="name">Change Password User</field>
|
||||||
|
<field name="inherit_id" ref="base.change_password_user_form_view"/>
|
||||||
|
<field name="model">change.password.user</field>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<xpath expr="//field[@name='new_passwd']" position="attributes">
|
||||||
|
<attribute name="widget">password_meter</attribute>
|
||||||
|
</xpath>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
</odoo>
|
</odoo>
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ class TestSelfAccessProfile(TestHrCommon):
|
|||||||
})
|
})
|
||||||
view = self.env.ref('hr.res_users_view_form_profile')
|
view = self.env.ref('hr.res_users_view_form_profile')
|
||||||
available_actions = james.get_views([(view.id, 'form')], {'toolbar': True})['views']['form']['toolbar']['action']
|
available_actions = james.get_views([(view.id, 'form')], {'toolbar': True})['views']['form']['toolbar']['action']
|
||||||
change_password_action = self.env.ref("base.change_password_wizard_action")
|
change_password_action = self.env.ref("base.change_password_action_server")
|
||||||
|
|
||||||
self.assertFalse(any(x['id'] == change_password_action.id for x in available_actions))
|
self.assertFalse(any(x['id'] == change_password_action.id for x in available_actions))
|
||||||
|
|
||||||
|
|||||||
@@ -1796,6 +1796,32 @@ class UsersView(models.Model):
|
|||||||
})
|
})
|
||||||
return res
|
return res
|
||||||
|
|
||||||
|
def action_change_password(self):
|
||||||
|
if len(self) == 1:
|
||||||
|
view_id = self.env.ref('base.change_password_user_form_view').id
|
||||||
|
return {
|
||||||
|
'name': _('Change Password'),
|
||||||
|
'view_mode': 'form',
|
||||||
|
'target': 'new',
|
||||||
|
'res_model': 'change.password.user',
|
||||||
|
'type': 'ir.actions.act_window',
|
||||||
|
'view_id': view_id,
|
||||||
|
'views': [(view_id, 'form')],
|
||||||
|
'context': {
|
||||||
|
'default_user_id': self.id,
|
||||||
|
'default_user_login': self.login,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
else:
|
||||||
|
return {
|
||||||
|
'name': _('Change Passwords'),
|
||||||
|
'view_mode': 'form',
|
||||||
|
'target': 'new',
|
||||||
|
'res_model': 'change.password.wizard',
|
||||||
|
'type': 'ir.actions.act_window',
|
||||||
|
'views': [[False, 'form']],
|
||||||
|
}
|
||||||
|
|
||||||
class CheckIdentity(models.TransientModel):
|
class CheckIdentity(models.TransientModel):
|
||||||
""" Wizard used to re-check the user's credentials (password)
|
""" Wizard used to re-check the user's credentials (password)
|
||||||
|
|
||||||
@@ -1854,7 +1880,7 @@ class ChangePasswordUser(models.TransientModel):
|
|||||||
_name = 'change.password.user'
|
_name = 'change.password.user'
|
||||||
_description = 'User, Change Password Wizard'
|
_description = 'User, Change Password Wizard'
|
||||||
|
|
||||||
wizard_id = fields.Many2one('change.password.wizard', string='Wizard', required=True, ondelete='cascade')
|
wizard_id = fields.Many2one('change.password.wizard', string='Wizard', ondelete='cascade')
|
||||||
user_id = fields.Many2one('res.users', string='User', required=True, ondelete='cascade')
|
user_id = fields.Many2one('res.users', string='User', required=True, ondelete='cascade')
|
||||||
user_login = fields.Char(string='User Login', readonly=True)
|
user_login = fields.Char(string='User Login', readonly=True)
|
||||||
new_passwd = fields.Char(string='New Password', default='')
|
new_passwd = fields.Char(string='New Password', default='')
|
||||||
|
|||||||
@@ -39,17 +39,45 @@
|
|||||||
<!-- the user list is editable, but one cannot add or delete rows -->
|
<!-- the user list is editable, but one cannot add or delete rows -->
|
||||||
<tree string="Users" editable="bottom" create="false" delete="false">
|
<tree string="Users" editable="bottom" create="false" delete="false">
|
||||||
<field name="user_id" invisible="1"/>
|
<field name="user_id" invisible="1"/>
|
||||||
<field name="user_login"/>
|
<field name="user_login" force_save="1"/>
|
||||||
<field name="new_passwd" required="True" password="True"/>
|
<field name="new_passwd" required="True" password="True"/>
|
||||||
</tree>
|
</tree>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
<record id="change_password_wizard_action" model="ir.actions.act_window">
|
|
||||||
|
<record id="change_password_user_form_view" model="ir.ui.view">
|
||||||
|
<field name="name">Change Password User</field>
|
||||||
|
<field name="model">change.password.user</field>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<form string="Change Password">
|
||||||
|
<field name="user_id" invisible="1"/>
|
||||||
|
<group>
|
||||||
|
<group>
|
||||||
|
<field name="user_login"/>
|
||||||
|
</group>
|
||||||
|
<group>
|
||||||
|
<field name="new_passwd" required="True" password="True" force_save="1"/>
|
||||||
|
</group>
|
||||||
|
</group>
|
||||||
|
<footer>
|
||||||
|
<button string="Change Password" name="change_password_button" type="object" class="btn-primary" data-hotkey="q"/>
|
||||||
|
<button string="Cancel" class="btn-secondary" special="cancel" data-hotkey="z"/>
|
||||||
|
</footer>
|
||||||
|
</form>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<record id="change_password_action_server" model="ir.actions.server">
|
||||||
<field name="name">Change Password</field>
|
<field name="name">Change Password</field>
|
||||||
<field name="res_model">change.password.wizard</field>
|
<field name="type">ir.actions.server</field>
|
||||||
<field name="view_mode">form</field>
|
<field name="model_id" ref="base.model_res_users"/>
|
||||||
<field name="target">new</field>
|
|
||||||
<field name="binding_model_id" ref="base.model_res_users"/>
|
<field name="binding_model_id" ref="base.model_res_users"/>
|
||||||
|
<field name="groups_id" eval="[(4,ref('base.group_erp_manager'))]"/>
|
||||||
|
<field name="state">code</field>
|
||||||
|
<field name="code">
|
||||||
|
if records:
|
||||||
|
action = records.action_change_password()
|
||||||
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
<record id="identity_check_wizard" model="ir.ui.view">
|
<record id="identity_check_wizard" model="ir.ui.view">
|
||||||
|
|||||||
Reference in New Issue
Block a user