Compare commits
4 Commits
c4d7e9b8a9
...
18.0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6e19575012 | ||
|
|
ae5977ef81 | ||
|
|
4581b3d019 | ||
|
|
bb6f12945f |
@@ -4,7 +4,14 @@ from odoo import api, fields, models
|
|||||||
class MaintenanceEquipment(models.Model):
|
class MaintenanceEquipment(models.Model):
|
||||||
_inherit = "maintenance.equipment"
|
_inherit = "maintenance.equipment"
|
||||||
|
|
||||||
|
_sql_constraints = [
|
||||||
|
('unique_name', 'UNIQUE(name)', 'Name must be unique.'),
|
||||||
|
('unique_server_ip', 'UNIQUE(server_ip)', 'Server IP must be unique.'),
|
||||||
|
('unique_ssh_target', 'UNIQUE(ssh_target)', 'Main Domain Name must be unique.'),
|
||||||
|
]
|
||||||
|
|
||||||
server_ip = fields.Char("Server Ip Address")
|
server_ip = fields.Char("Server Ip Address")
|
||||||
|
ssh_target = fields.Char("SSH Target", )
|
||||||
distribution_id = fields.Many2one("os.distribution", string="Distribution")
|
distribution_id = fields.Many2one("os.distribution", string="Distribution")
|
||||||
service_ids = fields.One2many("service.instance", "equipment_id", string="Services")
|
service_ids = fields.One2many("service.instance", "equipment_id", string="Services")
|
||||||
hosting_city = fields.Char("Hosting City")
|
hosting_city = fields.Char("Hosting City")
|
||||||
@@ -17,8 +24,24 @@ class MaintenanceEquipment(models.Model):
|
|||||||
|
|
||||||
name_fr = fields.Char("Name (FR)", compute="_compute_name_fr", store=True)
|
name_fr = fields.Char("Name (FR)", compute="_compute_name_fr", store=True)
|
||||||
|
|
||||||
|
def copy_data(self, default=None):
|
||||||
|
default = dict(default or {})
|
||||||
|
if "server_ip" not in default:
|
||||||
|
default["server_ip"] = False
|
||||||
|
if "ssh_target" not in default:
|
||||||
|
default["ssh_target"] = False
|
||||||
|
vals_list = super().copy_data(default=default)
|
||||||
|
if "name" not in default:
|
||||||
|
for equipment, vals in zip(self, vals_list):
|
||||||
|
vals["name"] = self.env._("%s (copy)", equipment.name)
|
||||||
|
return vals_list
|
||||||
|
|
||||||
@api.depends("name")
|
@api.depends("name")
|
||||||
def _compute_name_fr(self):
|
def _compute_name_fr(self):
|
||||||
|
if not self.env["res.lang"]._lang_get("fr_FR"):
|
||||||
|
for record in self:
|
||||||
|
record.name_fr = record.name
|
||||||
|
return
|
||||||
for record in self:
|
for record in self:
|
||||||
record.name_fr = record.with_context(lang="fr_FR").name
|
record.name_fr = record.with_context(lang="fr_FR").name
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
<xpath expr="//field[@name='effective_date']/.." position="after">
|
<xpath expr="//field[@name='effective_date']/.." position="after">
|
||||||
<group name="server_data" string="Server data">
|
<group name="server_data" string="Server data">
|
||||||
<field name="server_ip" />
|
<field name="server_ip" />
|
||||||
|
<field name="ssh_target" />
|
||||||
<field name="hosting_city" />
|
<field name="hosting_city" />
|
||||||
<field name="distribution_id" />
|
<field name="distribution_id" />
|
||||||
<field name="nb_cores" />
|
<field name="nb_cores" />
|
||||||
@@ -45,6 +46,7 @@
|
|||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<xpath expr="//field[@name='category_id']" position="after">
|
<xpath expr="//field[@name='category_id']" position="after">
|
||||||
<field name="server_ip" optional="hide" />
|
<field name="server_ip" optional="hide" />
|
||||||
|
<field name="ssh_target" optional="hide" />
|
||||||
<field name="hosting_city" optional="hide" />
|
<field name="hosting_city" optional="hide" />
|
||||||
<field name="distribution_id" optional="hide" />
|
<field name="distribution_id" optional="hide" />
|
||||||
<field name="nb_cores" optional="hide" />
|
<field name="nb_cores" optional="hide" />
|
||||||
|
|||||||
2
maintenance_user_ssh_key/.gitignore
vendored
Normal file
2
maintenance_user_ssh_key/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
*.*~
|
||||||
|
*pyc
|
||||||
63
maintenance_user_ssh_key/README.md
Normal file
63
maintenance_user_ssh_key/README.md
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
==============================
|
||||||
|
maintenance_user_ssh_key
|
||||||
|
==============================
|
||||||
|
|
||||||
|
This module adds SSH key management to Odoo users. It introduces a new
|
||||||
|
``ssh.key`` model and a ``ssh_key_ids`` One2many field on ``res.users``.
|
||||||
|
|
||||||
|
It allows administrators to associate SSH public keys with each user for
|
||||||
|
authentication purposes (e.g., remote server access, deployment).
|
||||||
|
|
||||||
|
Features:
|
||||||
|
|
||||||
|
- **SSH Key model**: Store public keys per user.
|
||||||
|
- **User integration**: SSH keys are displayed and editable directly on the
|
||||||
|
user form view.
|
||||||
|
- **Access control**: All internal users can view SSH keys; only users with
|
||||||
|
``Settings / Administration`` rights can create, edit, or delete them.
|
||||||
|
|
||||||
|
# Installation
|
||||||
|
|
||||||
|
Use Odoo normal module installation procedure to install
|
||||||
|
``maintenance_user_ssh_key``.
|
||||||
|
|
||||||
|
This module depends on ``base`` and requires no external Python dependencies.
|
||||||
|
|
||||||
|
# Configuration
|
||||||
|
|
||||||
|
No specific configuration is required. After installation:
|
||||||
|
|
||||||
|
1. Go to *Settings > Users & Companies > Users*.
|
||||||
|
2. Open any user and navigate to the **SSH Keys** notebook page.
|
||||||
|
3. Add SSH keys with the public key content.
|
||||||
|
|
||||||
|
# Usage
|
||||||
|
|
||||||
|
## Managing SSH Keys
|
||||||
|
|
||||||
|
- Open a user form and go to the *SSH Keys* tab.
|
||||||
|
- Click **Add a line** and paste the public key content.
|
||||||
|
|
||||||
|
# Bug Tracker
|
||||||
|
|
||||||
|
Bugs are tracked on
|
||||||
|
`our issues website <https://git.elabore.coop/Elabore/maintenance-tools/issues>`_.
|
||||||
|
In case of trouble, please check there if your issue has already been reported.
|
||||||
|
If you spotted it first, help us smashing it by providing a detailed and
|
||||||
|
welcomed feedback.
|
||||||
|
|
||||||
|
# Credits
|
||||||
|
|
||||||
|
## Contributors
|
||||||
|
|
||||||
|
- Stéphan Sainléger
|
||||||
|
|
||||||
|
## Funders
|
||||||
|
|
||||||
|
The development of this module has been financially supported by:
|
||||||
|
|
||||||
|
- Elabore (https://elabore.coop)
|
||||||
|
|
||||||
|
## Maintainer
|
||||||
|
|
||||||
|
This module is maintained by Elabore.
|
||||||
1
maintenance_user_ssh_key/__init__.py
Normal file
1
maintenance_user_ssh_key/__init__.py
Normal file
@@ -0,0 +1 @@
|
|||||||
|
from . import models
|
||||||
22
maintenance_user_ssh_key/__manifest__.py
Normal file
22
maintenance_user_ssh_key/__manifest__.py
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
# Copyright 2026 Stéphan Sainléger (Elabore)
|
||||||
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||||
|
|
||||||
|
{
|
||||||
|
"name": "maintenance_user_ssh_key",
|
||||||
|
"version": "18.0.1.0.0",
|
||||||
|
"author": "Elabore",
|
||||||
|
"website": "https://git.elabore.coop/elabore/maintenance-tools",
|
||||||
|
"maintainer": "Stéphan Sainléger",
|
||||||
|
"license": "AGPL-3",
|
||||||
|
"category": "Tools",
|
||||||
|
"summary": "Manage SSH keys per user.",
|
||||||
|
"depends": ["base"],
|
||||||
|
"data": [
|
||||||
|
"security/ir.model.access.csv",
|
||||||
|
"views/ssh_key_views.xml",
|
||||||
|
"views/res_users_views.xml",
|
||||||
|
],
|
||||||
|
"installable": True,
|
||||||
|
"auto_install": False,
|
||||||
|
"application": False,
|
||||||
|
}
|
||||||
2
maintenance_user_ssh_key/models/__init__.py
Normal file
2
maintenance_user_ssh_key/models/__init__.py
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
from . import ssh_key
|
||||||
|
from . import res_users
|
||||||
14
maintenance_user_ssh_key/models/res_users.py
Normal file
14
maintenance_user_ssh_key/models/res_users.py
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
# Copyright 2026 Stéphan Sainléger (Elabore)
|
||||||
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||||
|
|
||||||
|
from odoo import fields, models
|
||||||
|
|
||||||
|
|
||||||
|
class ResUsers(models.Model):
|
||||||
|
_inherit = "res.users"
|
||||||
|
|
||||||
|
ssh_key_ids = fields.One2many(
|
||||||
|
comodel_name="ssh.key",
|
||||||
|
inverse_name="user_id",
|
||||||
|
string="SSH Keys",
|
||||||
|
)
|
||||||
18
maintenance_user_ssh_key/models/ssh_key.py
Normal file
18
maintenance_user_ssh_key/models/ssh_key.py
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
# Copyright 2026 Stéphan Sainléger (Elabore)
|
||||||
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||||
|
|
||||||
|
from odoo import fields, models
|
||||||
|
|
||||||
|
|
||||||
|
class SshKey(models.Model):
|
||||||
|
_name = "ssh.key"
|
||||||
|
_description = "SSH Key"
|
||||||
|
|
||||||
|
key = fields.Text(string="Public Key", required=True)
|
||||||
|
user_id = fields.Many2one(
|
||||||
|
comodel_name="res.users",
|
||||||
|
string="User",
|
||||||
|
required=True,
|
||||||
|
ondelete="cascade",
|
||||||
|
index=True,
|
||||||
|
)
|
||||||
3
maintenance_user_ssh_key/security/ir.model.access.csv
Normal file
3
maintenance_user_ssh_key/security/ir.model.access.csv
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
id,name,model_id/id,group_id/id,perm_read,perm_write,perm_create,perm_unlink
|
||||||
|
access_ssh_key_user,ssh.key.user,model_ssh_key,base.group_user,1,0,0,0
|
||||||
|
access_ssh_key_manager,ssh.key.manager,model_ssh_key,base.group_system,1,1,1,1
|
||||||
|
21
maintenance_user_ssh_key/views/res_users_views.xml
Normal file
21
maintenance_user_ssh_key/views/res_users_views.xml
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<odoo>
|
||||||
|
|
||||||
|
<record id="view_users_form_ssh_key_inherit" model="ir.ui.view">
|
||||||
|
<field name="name">res.users.form.ssh.key</field>
|
||||||
|
<field name="model">res.users</field>
|
||||||
|
<field name="inherit_id" ref="base.view_users_form"/>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<xpath expr="//notebook" position="inside">
|
||||||
|
<page string="SSH Keys" name="ssh_keys">
|
||||||
|
<field name="ssh_key_ids">
|
||||||
|
<list editable="top">
|
||||||
|
<field name="key"/>
|
||||||
|
</list>
|
||||||
|
</field>
|
||||||
|
</page>
|
||||||
|
</xpath>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
</odoo>
|
||||||
44
maintenance_user_ssh_key/views/ssh_key_views.xml
Normal file
44
maintenance_user_ssh_key/views/ssh_key_views.xml
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<odoo>
|
||||||
|
|
||||||
|
<record id="ssh_key_view_tree" model="ir.ui.view">
|
||||||
|
<field name="name">ssh.key.tree</field>
|
||||||
|
<field name="model">ssh.key</field>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<list editable="top">
|
||||||
|
<field name="key"/>
|
||||||
|
<field name="user_id"/>
|
||||||
|
</list>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<record id="ssh_key_view_form" model="ir.ui.view">
|
||||||
|
<field name="name">ssh.key.form</field>
|
||||||
|
<field name="model">ssh.key</field>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<form>
|
||||||
|
<sheet>
|
||||||
|
<group>
|
||||||
|
<field name="user_id"/>
|
||||||
|
</group>
|
||||||
|
<group>
|
||||||
|
<field name="key" nolabel="1"/>
|
||||||
|
</group>
|
||||||
|
</sheet>
|
||||||
|
</form>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<record id="ssh_key_action" model="ir.actions.act_window">
|
||||||
|
<field name="name">SSH Keys</field>
|
||||||
|
<field name="res_model">ssh.key</field>
|
||||||
|
<field name="view_mode">list,form</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<menuitem
|
||||||
|
id="menu_ssh_key"
|
||||||
|
action="ssh_key_action"
|
||||||
|
parent="base.menu_security"
|
||||||
|
sequence="50"/>
|
||||||
|
|
||||||
|
</odoo>
|
||||||
Reference in New Issue
Block a user