3 Commits

Author SHA1 Message Date
Stéphan Sainléger
3639238d63 [IMP] maintenance_server_data: add unique constraint rule on some equipement fields
Some checks failed
pre-commit / pre-commit (pull_request) Failing after 6m8s
2026-06-30 16:17:04 +02:00
Stéphan Sainléger
e4c485576c [FIX] maintenance_server_data: add code protection if fr_FR language not installed 2026-06-30 16:16:31 +02:00
Stéphan Sainléger
3e7e30ac14 [IMP] maintenance_server_data: add main_domain_name field in equipments 2026-06-30 11:20:36 +02:00
12 changed files with 6 additions and 196 deletions

View File

@@ -7,11 +7,11 @@ class MaintenanceEquipment(models.Model):
_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.'),
('unique_main_domain_name', 'UNIQUE(main_domain_name)', 'Main Domain Name must be unique.'),
]
server_ip = fields.Char("Server Ip Address")
ssh_target = fields.Char("SSH Target", )
main_domain_name = fields.Char("Main Domain Name", )
distribution_id = fields.Many2one("os.distribution", string="Distribution")
service_ids = fields.One2many("service.instance", "equipment_id", string="Services")
hosting_city = fields.Char("Hosting City")
@@ -28,8 +28,8 @@ class MaintenanceEquipment(models.Model):
default = dict(default or {})
if "server_ip" not in default:
default["server_ip"] = False
if "ssh_target" not in default:
default["ssh_target"] = False
if "main_domain_name" not in default:
default["main_domain_name"] = False
vals_list = super().copy_data(default=default)
if "name" not in default:
for equipment, vals in zip(self, vals_list):

View File

@@ -8,7 +8,7 @@
<xpath expr="//field[@name='effective_date']/.." position="after">
<group name="server_data" string="Server data">
<field name="server_ip" />
<field name="ssh_target" />
<field name="main_domain_name" />
<field name="hosting_city" />
<field name="distribution_id" />
<field name="nb_cores" />
@@ -46,7 +46,7 @@
<field name="arch" type="xml">
<xpath expr="//field[@name='category_id']" position="after">
<field name="server_ip" optional="hide" />
<field name="ssh_target" optional="hide" />
<field name="main_domain_name" optional="hide" />
<field name="hosting_city" optional="hide" />
<field name="distribution_id" optional="hide" />
<field name="nb_cores" optional="hide" />

View File

@@ -1,2 +0,0 @@
*.*~
*pyc

View File

@@ -1,63 +0,0 @@
==============================
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.

View File

@@ -1 +0,0 @@
from . import models

View File

@@ -1,22 +0,0 @@
# 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,
}

View File

@@ -1,2 +0,0 @@
from . import ssh_key
from . import res_users

View File

@@ -1,14 +0,0 @@
# 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",
)

View File

@@ -1,18 +0,0 @@
# 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,
)

View File

@@ -1,3 +0,0 @@
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
1 id name model_id/id group_id/id perm_read perm_write perm_create perm_unlink
2 access_ssh_key_user ssh.key.user model_ssh_key base.group_user 1 0 0 0
3 access_ssh_key_manager ssh.key.manager model_ssh_key base.group_system 1 1 1 1

View File

@@ -1,21 +0,0 @@
<?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>

View File

@@ -1,44 +0,0 @@
<?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>