User Password Bundle automation
This commit is contained in:
parent
19789c2a76
commit
b797015c0e
7 changed files with 169 additions and 0 deletions
3
bemade_user_password_bundle/__init__.py
Normal file
3
bemade_user_password_bundle/__init__.py
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
from . import models
|
||||
25
bemade_user_password_bundle/__manifest__.py
Normal file
25
bemade_user_password_bundle/__manifest__.py
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
{
|
||||
'name': "User Password Bundle",
|
||||
|
||||
'summary': """
|
||||
Module to create password bundles and provide access to them for admins of a newly created user.
|
||||
""",
|
||||
|
||||
'description': """
|
||||
This module automate the creation of a password bundle for new users in Odoo 15 and changes the default admin
|
||||
ownership of bundle to admin/setting group instead of the bundle creator.
|
||||
""",
|
||||
|
||||
'author': "Bemade",
|
||||
'website': "https://www.bemade.org",
|
||||
'category': 'Technical',
|
||||
'version': '0.1',
|
||||
'license': 'AGPL-3',
|
||||
'depends': ['odoo_password_manager'],
|
||||
|
||||
'data': [
|
||||
],
|
||||
'demo': [
|
||||
],
|
||||
}
|
||||
4
bemade_user_password_bundle/models/__init__.py
Normal file
4
bemade_user_password_bundle/models/__init__.py
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
from . import res_users
|
||||
from . import password_bundle
|
||||
30
bemade_user_password_bundle/models/password_bundle.py
Normal file
30
bemade_user_password_bundle/models/password_bundle.py
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
from odoo import models, fields, api
|
||||
|
||||
|
||||
class password_bundle(models.Model):
|
||||
_inherit = 'password.bundle'
|
||||
_name = 'password.bundle'
|
||||
|
||||
@api.model
|
||||
def _default_access_admin_ids(self):
|
||||
"""
|
||||
Default method for access_ids
|
||||
"""
|
||||
values = {
|
||||
'access_level': 'admin',
|
||||
'group_id': self.env.ref('base.group_system').id,
|
||||
}
|
||||
return [(0, 0, values)]
|
||||
|
||||
# BV: UGLY HACK
|
||||
# I should be able to remove this field, but I can't just override the default function
|
||||
# _default_access_ids, so I rename it _default_access_admin_ids and override the th field
|
||||
|
||||
access_ids = fields.One2many(
|
||||
"password.access",
|
||||
"bundle_id",
|
||||
default=_default_access_admin_ids,
|
||||
)
|
||||
|
||||
23
bemade_user_password_bundle/models/res_users.py
Normal file
23
bemade_user_password_bundle/models/res_users.py
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
from odoo import models, fields, api
|
||||
|
||||
|
||||
class ResUsers(models.Model):
|
||||
_inherit = 'res.users'
|
||||
|
||||
@api.model
|
||||
def create(self, vals):
|
||||
newuser = super(ResUsers, self).create(vals)
|
||||
if vals.get("sel_groups_1_9_10", 9) == 1:
|
||||
pw_bundle = self.env['password.bundle'].create({
|
||||
'name': newuser.name,
|
||||
})
|
||||
self.env['password.access'].create({
|
||||
'bundle_id': pw_bundle.id,
|
||||
'user_id': newuser.id,
|
||||
'access_level': 'full'
|
||||
})
|
||||
|
||||
return newuser
|
||||
|
||||
24
bemade_user_password_bundle/views/templates.xml
Normal file
24
bemade_user_password_bundle/views/templates.xml
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
<odoo>
|
||||
<data>
|
||||
<!--
|
||||
<template id="listing">
|
||||
<ul>
|
||||
<li t-foreach="objects" t-as="object">
|
||||
<a t-attf-href="#{ root }/objects/#{ object.id }">
|
||||
<t t-esc="object.display_name"/>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</template>
|
||||
<template id="object">
|
||||
<h1><t t-esc="object.display_name"/></h1>
|
||||
<dl>
|
||||
<t t-foreach="object._fields" t-as="field">
|
||||
<dt><t t-esc="field"/></dt>
|
||||
<dd><t t-esc="object[field]"/></dd>
|
||||
</t>
|
||||
</dl>
|
||||
</template>
|
||||
-->
|
||||
</data>
|
||||
</odoo>
|
||||
60
bemade_user_password_bundle/views/views.xml
Normal file
60
bemade_user_password_bundle/views/views.xml
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
<odoo>
|
||||
<data>
|
||||
<!-- explicit list view definition -->
|
||||
<!--
|
||||
<record model="ir.ui.view" id="bemade_user_password_bundle.list">
|
||||
<field name="name">bemade_user_password_bundle list</field>
|
||||
<field name="model">bemade_user_password_bundle.bemade_user_password_bundle</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree>
|
||||
<field name="name"/>
|
||||
<field name="value"/>
|
||||
<field name="value2"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
-->
|
||||
|
||||
<!-- actions opening views on models -->
|
||||
<!--
|
||||
<record model="ir.actions.act_window" id="bemade_user_password_bundle.action_window">
|
||||
<field name="name">bemade_user_password_bundle window</field>
|
||||
<field name="res_model">bemade_user_password_bundle.bemade_user_password_bundle</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
</record>
|
||||
-->
|
||||
|
||||
<!-- server action to the one above -->
|
||||
<!--
|
||||
<record model="ir.actions.server" id="bemade_user_password_bundle.action_server">
|
||||
<field name="name">bemade_user_password_bundle server</field>
|
||||
<field name="model_id" ref="model_bemade_user_password_bundle_bemade_user_password_bundle"/>
|
||||
<field name="state">code</field>
|
||||
<field name="code">
|
||||
action = {
|
||||
"type": "ir.actions.act_window",
|
||||
"view_mode": "tree,form",
|
||||
"res_model": model._name,
|
||||
}
|
||||
</field>
|
||||
</record>
|
||||
-->
|
||||
|
||||
<!-- Top menu item -->
|
||||
<!--
|
||||
<menuitem name="bemade_user_password_bundle" id="bemade_user_password_bundle.menu_root"/>
|
||||
-->
|
||||
<!-- menu categories -->
|
||||
<!--
|
||||
<menuitem name="Menu 1" id="bemade_user_password_bundle.menu_1" parent="bemade_user_password_bundle.menu_root"/>
|
||||
<menuitem name="Menu 2" id="bemade_user_password_bundle.menu_2" parent="bemade_user_password_bundle.menu_root"/>
|
||||
-->
|
||||
<!-- actions -->
|
||||
<!--
|
||||
<menuitem name="List" id="bemade_user_password_bundle.menu_1_list" parent="bemade_user_password_bundle.menu_1"
|
||||
action="bemade_user_password_bundle.action_window"/>
|
||||
<menuitem name="Server to list" id="bemade_user_password_bundle" parent="bemade_user_password_bundle.menu_2"
|
||||
action="bemade_user_password_bundle.action_server"/>
|
||||
-->
|
||||
</data>
|
||||
</odoo>
|
||||
Loading…
Reference in a new issue