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
27 changed files with 184 additions and 955 deletions

View File

@@ -1,42 +0,0 @@
#!/bin/bash
#
# Run the Python tests of the given Odoo modules.
#
# This script is meant to be executed *inside* an Elabore doodba image
# (docker.0k.io/mirror/odoo:rc_<version>-ELABORE-LIGHT), with a
# PostgreSQL service reachable at $PGHOST. The modules under test are
# read from the current working directory (the checked-out repository),
# which is prepended to the addons path so that the PR's code takes
# precedence over the modules already baked in the image.
#
# Usage: odoo-tests.sh <module1,module2,...>
set -euo pipefail
modules="${1:?usage: odoo-tests.sh <module1,module2,...>}"
export PGHOST=postgres
export PGUSER=odoo
export PGPASSWORD=odoopassword
export PGDATABASE="test_$(basename "$PWD" | tr '.-' '__')"
export WITHOUT_DEMO=all
export DB_FILTER='.*'
# Generate /opt/odoo/auto/odoo.conf from the environment and wait for
# the database to accept connections.
/opt/odoo/common/entrypoint
# Odoo test-tags format: "/module1,/module2" (one leading slash).
tags="/$(echo "$modules" | tr ',' ',/')"
exec odoo \
--config=/opt/odoo/auto/odoo.conf \
--max-cron-threads=0 \
--limit-time-real=10000 \
--workers=0 \
--test-enable \
--stop-after-init \
--addons-path="$PWD,/opt/odoo/auto/addons" \
-d "$PGDATABASE" \
-i "$modules" \
--test-tags "$tags"

View File

@@ -1,79 +0,0 @@
name: tests
on:
pull_request:
branches:
- "18.0*"
workflow_dispatch:
jobs:
test:
runs-on: odoo-ci
container:
image: docker.0k.io/mirror/odoo:rc_18.0-ELABORE-LIGHT
services:
postgres:
image: docker.0k.io/postgres:17.2.0-myc
env:
POSTGRES_USER: odoo
POSTGRES_PASSWORD: odoopassword
POSTGRES_DB: postgres
steps:
# The doodba image ships no Node.js, so actions/checkout@v4 cannot
# run here. The repository is private, so the job token is required.
- name: Checkout
env:
SECRET_GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
SECRET_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -eu
token="${GITEA_TOKEN:-${GITHUB_TOKEN:-${SECRET_GITEA_TOKEN:-${SECRET_GITHUB_TOKEN:-}}}}"
if [ -z "$token" ]; then
echo "::error::No job token available to clone the repository"
exit 1
fi
server="${GITHUB_SERVER_URL:-https://git.elabore.coop}"
repo="${GITHUB_REPOSITORY:?GITHUB_REPOSITORY is not set}"
ref="${GITHUB_REF:-${GITHUB_SHA:?neither GITHUB_REF nor GITHUB_SHA is set}}"
auth_url="$(printf '%s' "${server%/}/${repo}.git" |
sed -E "s#^https://#https://${token}@#")"
git init -q .
git config --global --add safe.directory "$PWD"
git remote add origin "$auth_url"
git fetch -q --depth=1 origin "$ref"
git checkout -q FETCH_HEAD
- name: Detect changed modules
id: changed
run: |
set -eu
if [ -n "${GITHUB_BASE_REF:-}" ]; then
git fetch -q --depth=1 origin "refs/heads/$GITHUB_BASE_REF"
base_rev="FETCH_HEAD"
scope="diff against $GITHUB_BASE_REF"
else
base_rev=""
scope="all installable modules (manual run)"
fi
if [ -n "$base_rev" ]; then
modules="$(
git diff --name-only "$base_rev" HEAD |
awk -F/ '{print $1}' | sort -u |
while read -r dir; do
[ -f "$dir/__manifest__.py" ] && echo "$dir"
done | paste -sd, -
)"
else
modules="$(
for dir in */; do
dir="${dir%/}"
[ -f "$dir/__manifest__.py" ] && echo "$dir"
done | paste -sd, -
)"
fi
echo "modules=$modules" >> "$GITHUB_OUTPUT"
echo "Modules to test ($scope): ${modules:-<none>}"
- name: Run Odoo tests
if: steps.changed.outputs.modules != ''
run: bash .gitea/scripts/odoo-tests.sh "${{ steps.changed.outputs.modules }}"

88
.gitignore vendored
View File

@@ -1,88 +0,0 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
/.venv
/.pytest_cache
/.ruff_cache
# C extensions
*.so
# Distribution / packaging
.Python
env/
bin/
build/
develop-eggs/
dist/
eggs/
lib64/
parts/
sdist/
var/
*.egg-info/
.installed.cfg
*.egg
*.eggs
# Windows installers
*.msi
# Debian packages
*.deb
# Redhat packages
*.rpm
# MacOS packages
*.dmg
*.pkg
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.cache
nosetests.xml
coverage.xml
# Translations
*.mo
# Pycharm
.idea
# Eclipse
.settings
# Visual Studio cache/options directory
.vs/
.vscode
# OSX Files
.DS_Store
# Django stuff:
*.log
# Mr Developer
.mr.developer.cfg
.project
.pydevproject
# Rope
.ropeproject
# Sphinx documentation
docs/_build/
# Backup files
*~
*.swp
# OCA rules
!static/lib/

View File

@@ -22,7 +22,7 @@ exclude: |
(LICENSE.*|COPYING.*)
default_language_version:
python: python3
node: "22.9.0"
node: "16.17.0"
repos:
- repo: local
hooks:
@@ -38,12 +38,8 @@ repos:
entry: found a en.po file
language: fail
files: '[a-zA-Z0-9_]*/i18n/en\.po$'
- repo: https://github.com/sbidoul/whool
rev: v1.3
hooks:
- id: whool-init
- repo: https://github.com/oca/maintainer-tools
rev: b89f767503be6ab2b11e4f50a7557cb20066e667
rev: f9b919b9868143135a9c9cb03021089cabba8223
hooks:
# update the NOT INSTALLABLE ADDONS section above
- id: oca-update-pre-commit-excluded-addons
@@ -56,10 +52,10 @@ repos:
bash -c 'oca-gen-addon-readme --addons-dir=. --branch=$(git symbolic-ref
refs/remotes/origin/HEAD | sed "s@^refs/remotes/origin/@@")
--repo-name=$(basename $(git rev-parse --show-toplevel)) --org-name="Elabore"
--if-source-changed --keep-source-digest --convert-fragments-to-markdown'
- id: oca-gen-external-dependencies
--if-source-changed --keep-source-digest'
- repo: https://github.com/OCA/odoo-pre-commit-hooks
rev: v0.0.33
rev: v0.1.4
hooks:
- id: oca-checks-odoo-module
- id: oca-checks-po
@@ -78,8 +74,8 @@ repos:
files: \.(css|htm|html|js|json|jsx|less|md|scss|toml|ts|xml|yaml|yml)$
language: node
additional_dependencies:
- "prettier@3.3.3"
- "@prettier/plugin-xml@3.4.1"
- "prettier@2.7.1"
- "@prettier/plugin-xml@2.2.0"
- repo: local
hooks:
- id: eslint
@@ -92,11 +88,10 @@ repos:
types: [javascript]
language: node
additional_dependencies:
- "eslint@9.12.0"
- "eslint-plugin-jsdoc@50.3.1"
- "globals@16.0.0"
- "eslint@8.24.0"
- "eslint-plugin-jsdoc@"
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
rev: v5.0.0
hooks:
- id: trailing-whitespace
# exclude autogenerated files
@@ -117,8 +112,23 @@ repos:
- id: check-xml
- id: mixed-line-ending
args: ["--fix=lf"]
- repo: https://github.com/PyCQA/docformatter
rev: v1.7.7
hooks:
- id: docformatter
args: [
"--in-place", # modify the files
"--recursive", # run on all the files
"--wrap-summaries",
"88", # max length of 1st line
"--wrap-descriptions",
"88", # max length of other lines
"--pre-summary-newline", # new line before a long summary
"--make-summary-multi-line", # force summary on multilines
]
additional_dependencies: ["tomli"] # if Python <3.11
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.6.8
rev: v0.12.0
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]

View File

@@ -10,7 +10,7 @@ manifest-required-authors=Elabore
manifest-required-keys=license
manifest-deprecated-keys=description,active
license-allowed=AGPL-3,GPL-2,GPL-2 or any later version,GPL-3,GPL-3 or any later version,LGPL-3
valid-odoo-versions=18.0
valid-odoo-versions=16.0
[MESSAGES CONTROL]
disable=all
@@ -25,25 +25,19 @@ disable=all
enable=anomalous-backslash-in-string,
api-one-deprecated,
api-one-multi-together,
assignment-from-none,
attribute-deprecated,
class-camelcase,
dangerous-default-value,
dangerous-view-replace-wo-priority,
development-status-allowed,
duplicate-id-csv,
duplicate-key,
duplicate-xml-fields,
duplicate-xml-record-id,
eval-referenced,
incoherent-interpreter-exec-perm,
openerp-exception-warning,
redundant-modulename-xml,
relative-import,
rst-syntax-error,
wrong-tabs-instead-of-spaces,
xml-syntax-error,
assignment-from-none,
attribute-deprecated,
dangerous-default-value,
development-status-allowed,
duplicate-key,
eval-used,
incoherent-interpreter-exec-perm,
license-allowed,
manifest-author-string,
manifest-deprecated-key,
@@ -54,68 +48,73 @@ enable=anomalous-backslash-in-string,
method-inverse,
method-required-super,
method-search,
openerp-exception-warning,
pointless-statement,
pointless-string-statement,
print-used,
redundant-keyword-arg,
redundant-modulename-xml,
reimported,
relative-import,
return-in-init,
rst-syntax-error,
sql-injection,
too-few-format-args,
translation-field,
translation-required,
unreachable,
use-vim-comment,
wrong-tabs-instead-of-spaces,
xml-syntax-error,
attribute-string-redundant,
character-not-valid-in-resource-link,
consider-merging-classes-inherited,
context-overridden,
create-user-wo-reset-password,
dangerous-filter-wo-user,
dangerous-qweb-replace-wo-priority,
deprecated-data-xml-node,
deprecated-openerp-xml-node,
duplicate-po-message-definition,
file-not-used,
missing-newline-extrafiles,
old-api7-method-defined,
po-msgstr-variables,
po-syntax-error,
str-format-used,
unnecessary-utf8-coding-comment,
xml-attribute-translatable,
xml-deprecated-qweb-directive,
xml-deprecated-tree-attribute,
attribute-string-redundant,
consider-merging-classes-inherited,
context-overridden,
except-pass,
file-not-used,
invalid-commit,
manifest-maintainers-list,
missing-newline-extrafiles,
missing-readme,
missing-return,
odoo-addons-relative-import,
old-api7-method-defined,
po-msgstr-variables,
po-syntax-error,
renamed-field-parameter,
resource-not-exist,
str-format-used,
test-folder-imported,
translation-contains-variable,
translation-positional-used,
website-manifest-key-not-valid-uri,
external-request-timeout,
missing-manifest-dependency,
too-complex,,
create-user-wo-reset-password,
dangerous-filter-wo-user,
file-not-used,
missing-newline-extrafiles,
no-utf8-coding-comment,
old-api7-method-defined,
unnecessary-utf8-coding-comment,
website-manifest-key-not-valid-uri,
xml-attribute-translatable,
xml-deprecated-qweb-directive,
xml-deprecated-tree-attribute,
external-request-timeout,
# messages that do not cause the lint step to fail
consider-merging-classes-inherited,
create-user-wo-reset-password,
dangerous-filter-wo-user,
deprecated-module,
file-not-used,
invalid-commit,
missing-manifest-dependency,
missing-newline-extrafiles,
missing-readme,
no-utf8-coding-comment,
odoo-addons-relative-import,
old-api7-method-defined,
redefined-builtin,
manifest-external-assets
too-complex,
unnecessary-utf8-coding-comment
[REPORTS]

View File

@@ -9,7 +9,7 @@ manifest-required-authors=Elabore
manifest-required-keys=license
manifest-deprecated-keys=description,active
license-allowed=AGPL-3,GPL-2,GPL-2 or any later version,GPL-3,GPL-3 or any later version,LGPL-3
valid-odoo-versions=18.0
valid-odoo-versions=16.0
[MESSAGES CONTROL]
disable=all
@@ -17,25 +17,19 @@ disable=all
enable=anomalous-backslash-in-string,
api-one-deprecated,
api-one-multi-together,
assignment-from-none,
attribute-deprecated,
class-camelcase,
dangerous-default-value,
dangerous-view-replace-wo-priority,
development-status-allowed,
duplicate-id-csv,
duplicate-key,
duplicate-xml-fields,
duplicate-xml-record-id,
eval-referenced,
incoherent-interpreter-exec-perm,
openerp-exception-warning,
redundant-modulename-xml,
relative-import,
rst-syntax-error,
wrong-tabs-instead-of-spaces,
xml-syntax-error,
assignment-from-none,
attribute-deprecated,
dangerous-default-value,
development-status-allowed,
duplicate-key,
eval-used,
incoherent-interpreter-exec-perm,
license-allowed,
manifest-author-string,
manifest-deprecated-key,
@@ -46,50 +40,56 @@ enable=anomalous-backslash-in-string,
method-inverse,
method-required-super,
method-search,
openerp-exception-warning,
pointless-statement,
pointless-string-statement,
print-used,
redundant-keyword-arg,
redundant-modulename-xml,
reimported,
relative-import,
return-in-init,
rst-syntax-error,
sql-injection,
too-few-format-args,
translation-field,
translation-required,
unreachable,
use-vim-comment,
wrong-tabs-instead-of-spaces,
xml-syntax-error,
attribute-string-redundant,
character-not-valid-in-resource-link,
consider-merging-classes-inherited,
context-overridden,
create-user-wo-reset-password,
dangerous-filter-wo-user,
dangerous-qweb-replace-wo-priority,
deprecated-data-xml-node,
deprecated-openerp-xml-node,
duplicate-po-message-definition,
file-not-used,
missing-newline-extrafiles,
old-api7-method-defined,
po-msgstr-variables,
po-syntax-error,
str-format-used,
unnecessary-utf8-coding-comment,
xml-attribute-translatable,
xml-deprecated-qweb-directive,
xml-deprecated-tree-attribute,
attribute-string-redundant,
consider-merging-classes-inherited,
context-overridden,
except-pass,
file-not-used,
invalid-commit,
manifest-maintainers-list,
missing-newline-extrafiles,
missing-readme,
missing-return,
odoo-addons-relative-import,
old-api7-method-defined,
po-msgstr-variables,
po-syntax-error,
renamed-field-parameter,
resource-not-exist,
str-format-used,
test-folder-imported,
translation-contains-variable,
translation-positional-used,
unnecessary-utf8-coding-comment,
website-manifest-key-not-valid-uri,
xml-attribute-translatable,
xml-deprecated-qweb-directive,
xml-deprecated-tree-attribute,
external-request-timeout
[REPORTS]

View File

@@ -1,205 +0,0 @@
var globals = require('globals');
jsdoc = require("eslint-plugin-jsdoc");
const config = [{
plugins: {
jsdoc,
},
languageOptions: {
globals: {
_: "readonly",
$: "readonly",
fuzzy: "readonly",
jQuery: "readonly",
moment: "readonly",
odoo: "readonly",
openerp: "readonly",
owl: "readonly",
luxon: "readonly",
QUnit: "readonly",
...globals.browser,
},
ecmaVersion: 2024,
sourceType: "script",
},
rules: {
"accessor-pairs": "warn",
"array-callback-return": "warn",
"callback-return": "warn",
"capitalized-comments": ["warn", "always", {
ignoreConsecutiveComments: true,
ignoreInlineComments: true,
}],
complexity: ["warn", 15],
"constructor-super": "warn",
"dot-notation": "warn",
eqeqeq: "warn",
"global-require": "warn",
"handle-callback-err": "warn",
"id-blacklist": "warn",
"id-match": "warn",
"init-declarations": "error",
"max-depth": "warn",
"max-nested-callbacks": "warn",
"max-statements-per-line": "warn",
"no-alert": "warn",
"no-array-constructor": "warn",
"no-caller": "warn",
"no-case-declarations": "warn",
"no-class-assign": "warn",
"no-cond-assign": "error",
"no-const-assign": "error",
"no-constant-condition": "warn",
"no-control-regex": "warn",
"no-debugger": "error",
"no-delete-var": "warn",
"no-div-regex": "warn",
"no-dupe-args": "error",
"no-dupe-class-members": "error",
"no-dupe-keys": "error",
"no-duplicate-case": "error",
"no-duplicate-imports": "error",
"no-else-return": "warn",
"no-empty-character-class": "warn",
"no-empty-function": "error",
"no-empty-pattern": "error",
"no-empty": "warn",
"no-eq-null": "error",
"no-eval": "error",
"no-ex-assign": "error",
"no-extend-native": "warn",
"no-extra-bind": "warn",
"no-extra-boolean-cast": "warn",
"no-extra-label": "warn",
"no-fallthrough": "warn",
"no-func-assign": "error",
"no-global-assign": "error",
"no-implicit-coercion": ["warn", {
allow: ["~"],
}],
"no-implicit-globals": "warn",
"no-implied-eval": "warn",
"no-inline-comments": "warn",
"no-inner-declarations": "warn",
"no-invalid-regexp": "warn",
"no-irregular-whitespace": "warn",
"no-iterator": "warn",
"no-label-var": "warn",
"no-labels": "warn",
"no-lone-blocks": "warn",
"no-lonely-if": "error",
"no-mixed-requires": "error",
"no-multi-str": "warn",
"no-native-reassign": "error",
"no-negated-condition": "warn",
"no-negated-in-lhs": "error",
"no-new-func": "warn",
"no-new-object": "warn",
"no-new-require": "warn",
"no-new-symbol": "warn",
"no-new-wrappers": "warn",
"no-new": "warn",
"no-obj-calls": "warn",
"no-octal-escape": "warn",
"no-octal": "warn",
"no-param-reassign": "warn",
"no-path-concat": "warn",
"no-process-env": "warn",
"no-process-exit": "warn",
"no-proto": "warn",
"no-prototype-builtins": "warn",
"no-redeclare": "warn",
"no-regex-spaces": "warn",
"no-restricted-globals": "warn",
"no-restricted-imports": "warn",
"no-restricted-modules": "warn",
"no-restricted-syntax": "warn",
"no-return-assign": "error",
"no-script-url": "warn",
"no-self-assign": "warn",
"no-self-compare": "warn",
"no-sequences": "warn",
"no-shadow-restricted-names": "warn",
"no-shadow": "warn",
"no-sparse-arrays": "warn",
"no-sync": "warn",
"no-this-before-super": "warn",
"no-throw-literal": "warn",
"no-undef-init": "warn",
"no-undef": "error",
"no-unmodified-loop-condition": "warn",
"no-unneeded-ternary": "error",
"no-unreachable": "error",
"no-unsafe-finally": "error",
"no-unused-expressions": "error",
"no-unused-labels": "error",
"no-unused-vars": "error",
"no-use-before-define": "error",
"no-useless-call": "warn",
"no-useless-computed-key": "warn",
"no-useless-concat": "warn",
"no-useless-constructor": "warn",
"no-useless-escape": "warn",
"no-useless-rename": "warn",
"no-void": "warn",
"no-with": "warn",
"operator-assignment": ["error", "always"],
"prefer-const": "warn",
radix: "warn",
"require-yield": "warn",
"sort-imports": "warn",
"spaced-comment": ["error", "always"],
strict: ["error", "function"],
"use-isnan": "error",
"jsdoc/check-tag-names": "warn",
"jsdoc/check-types": "warn",
"jsdoc/require-param-description": "off",
"jsdoc/require-return": "off",
"jsdoc/require-return-description": "off",
"jsdoc/require-return-type": "off",
"valid-typeof": "warn",
yoda: "warn",
},
settings: {
jsdoc: {
tagNamePreference: {
arg: "param",
argument: "param",
augments: "extends",
constructor: "class",
exception: "throws",
func: "function",
method: "function",
prop: "property",
return: "returns",
virtual: "abstract",
yield: "yields",
},
preferredTypes: {
array: "Array",
bool: "Boolean",
boolean: "Boolean",
number: "Number",
object: "Object",
str: "String",
string: "String",
},
},
},
}, {
files: ["**/*.esm.js", "**/*test.js"],
languageOptions: {
ecmaVersion: 2024,
sourceType: "module",
},
}];
module.exports = config

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

@@ -39,19 +39,13 @@ By default, maintenance mode lasts 4 hours. To change this:
## Cron Jobs
Three scheduled actions are installed:
Two scheduled actions are installed:
1. **HTTP Service Monitoring: check all services**
- Runs every 10 minutes
- Discovery sweep: checks HTTP status of all active service instances with URLs
and flags the start of a KO streak
- Runs every 15 minutes
- Checks HTTP status of all active service instances with URLs
2. **HTTP Service Monitoring: confirm KO services**
- Runs every 2 minutes
- Re-checks only the services currently flagged KO (without an open request) and
creates a maintenance request once the outage is confirmed
3. **HTTP Service Monitoring: deactivate expired maintenance mode**
2. **HTTP Service Monitoring: deactivate expired maintenance mode**
- Runs every 15 minutes
- Automatically disables maintenance mode when the end time is reached
@@ -104,18 +98,14 @@ On service instances, you can see:
## Automatic Maintenance Requests
When a service fails HTTP checks:
- The 10-minute discovery sweep flags the outage (``http_first_ko_at``) but does
**not** create a request yet
- The 2-minute confirmation cron re-checks the flagged services only. A request is
created once the service has been continuously KO for at least 2 minutes
(``HTTP_KO_CONFIRMATION_DELAY``), so a short transient outage is not flagged
- A corrective maintenance request is created per failing service, named
``[HTTP KO] {service_url}``
- The request description includes the error detail: the HTTP status code,
or a network error label (timeout / DNS / SSL) when no HTTP response was received
- No duplicate is created as long as an open request already exists for that service
- The confirmation cron skips services that already have an open request; those are
handled by the discovery sweep
- A **double-check** is performed before creating the request: the service is retested
after 2 seconds. A maintenance request is only created if the service fails **both**
checks, reducing noise from transient HTTP errors
When a service recovers (returns HTTP 200 after having an open request):
- The open maintenance request is automatically moved to the first **done** stage

View File

@@ -5,7 +5,7 @@
"license": "AGPL-3",
"category": "Tools",
"summary": "Monitor HTTP availability of services",
"depends": ["base", "maintenance", "base_maintenance", "hr_maintenance", "maintenance_server_data"],
"depends": ["base", "maintenance", "hr_maintenance", "maintenance_server_data"],
"external_dependencies": {"python": ["requests"]},
"data": [
"data/ir_config_parameter.xml",

View File

@@ -5,15 +5,7 @@
<field name="model_id" ref="maintenance_server_data.model_service_instance" />
<field name="state">code</field>
<field name="code">model.cron_check_http_services()</field>
<field name="interval_number">10</field>
<field name="interval_type">minutes</field>
</record>
<record id="ir_cron_http_service_confirmation" model="ir.cron">
<field name="name">HTTP Service Monitoring : confirm KO services</field>
<field name="model_id" ref="maintenance_server_data.model_service_instance" />
<field name="state">code</field>
<field name="code">model.cron_confirm_http_ko_services()</field>
<field name="interval_number">2</field>
<field name="interval_number">15</field>
<field name="interval_type">minutes</field>
</record>
<record id="ir_cron_maintenance_mode_expiry" model="ir.cron">

View File

@@ -1,5 +1,5 @@
import logging
from datetime import timedelta
import time
from odoo import api, fields, models
@@ -10,8 +10,8 @@ except ImportError:
_logger = logging.getLogger(__name__)
HTTP_CHECK_TIMEOUT = 20 # seconds
HTTP_KO_CONFIRMATION_DELAY = timedelta(minutes=2)
HTTP_CHECK_TIMEOUT = 10 # seconds
HTTP_RETRY_DELAY = 2 # seconds between pass 1 and pass 2
class ServiceInstance(models.Model):
@@ -36,22 +36,14 @@ class ServiceInstance(models.Model):
string="HTTP Maintenance Request",
readonly=True,
)
http_first_ko_at = fields.Datetime(
string="First HTTP KO Check (current streak)",
readonly=True,
)
def check_http_status(self):
"""
Perform HTTP check for each record and return the KO recordset.
Writes last_http_status_code, last_http_check_date and http_status_ok on every
checked record, and maintains http_first_ko_at (the start of the current KO
streak, reset as soon as the service is OK again). Does NOT create
maintenance.request — that decision belongs to cron_confirm_http_ko_services,
once the service has been continuously KO for at least
HTTP_KO_CONFIRMATION_DELAY, to avoid flagging transient outages (e.g. a short
server overload) as real incidents.
checked record. Does NOT create maintenance.request — that decision belongs to
the caller (cron) after optional retry logic.
"""
ko_records = self.browse()
for rec in self:
@@ -71,16 +63,13 @@ class ServiceInstance(models.Model):
status_ok = status_code == 200
except requests.exceptions.RequestException as e:
_logger.warning("HTTP check failed for %s: %s", rec.service_url, e)
vals = {
"last_http_status_code": status_code,
"last_http_check_date": now,
"http_status_ok": status_ok,
}
if status_ok:
vals["http_first_ko_at"] = False
elif not rec.http_first_ko_at:
vals["http_first_ko_at"] = now
rec.write(vals)
rec.write(
{
"last_http_status_code": status_code,
"last_http_check_date": now,
"http_status_ok": status_ok,
}
)
if not status_ok:
ko_records |= rec
return ko_records
@@ -117,12 +106,13 @@ class ServiceInstance(models.Model):
@api.model
def cron_check_http_services(self):
"""
Discovery sweep: check all active services with a URL.
Check all active services with a URL, with one retry on failure.
This cron only detects outages — it flags the start of a KO streak through
http_first_ko_at (via check_http_status) and auto-resolves services that
recovered. Maintenance requests are created by the separate, faster
cron_confirm_http_ko_services once the outage is confirmed.
Pass 1: test every eligible service.
- Services that had an open request and are now OK are auto-resolved.
- Services still KO after pass 1 are retested after HTTP_RETRY_DELAY seconds.
maintenance.request is created only for services that fail both passes,
reducing noise from transient HTTP errors.
"""
domain = [
("active", "=", True),
@@ -133,48 +123,25 @@ class ServiceInstance(models.Model):
lambda s: not s.equipment_id.maintenance_mode
)
# Snapshot services that currently have an open request before the check
# Snapshot services that currently have an open request before pass 1
services_with_open_request = services.filtered(
lambda s: s.http_maintenance_request
and not s.http_maintenance_request.stage_id.done
)
services.check_http_status()
ko_after_pass1 = services.check_http_status()
# Auto-resolve services that recovered
# Auto-resolve services that recovered during pass 1
recovered = services_with_open_request.filtered(lambda s: s.http_status_ok)
if recovered:
recovered._close_http_maintenance_request()
@api.model
def cron_confirm_http_ko_services(self):
"""
Confirmation pass: re-check services currently flagged KO and create their
maintenance.request once the outage is confirmed.
if not ko_after_pass1:
return
Only services without an open request are considered (re-checking a service
already under an open request is pointless). A service must be continuously
KO for at least HTTP_KO_CONFIRMATION_DELAY: a service that recovered in the
meantime resets http_first_ko_at via check_http_status and no request is
created. Services already under an open request are handled by the slower
discovery cron, which also auto-resolves them when they recover.
"""
domain = [
("active", "=", True),
("service_url", "!=", False),
("equipment_id", "!=", False),
("http_first_ko_at", "!=", False),
("http_maintenance_request", "=", False),
]
services = self.search(domain).filtered(
lambda s: not s.equipment_id.maintenance_mode
)
time.sleep(HTTP_RETRY_DELAY)
ko_services = services.check_http_status()
ko_confirmed = ko_after_pass1.check_http_status()
confirmed_ko = ko_services.filtered(
lambda s: s.last_http_check_date - s.http_first_ko_at
>= HTTP_KO_CONFIRMATION_DELAY
)
for service in confirmed_ko:
for service in ko_confirmed:
service.equipment_id.create_http_maintenance_request(service)

View File

@@ -11,9 +11,9 @@ EQUIPMENT_HTTP_REQUESTS = (
"odoo.addons.maintenance_service_http_monitoring"
".models.maintenance_equipment.http_requests"
)
# Comfortably past HTTP_KO_CONFIRMATION_DELAY (currently 2 minutes).
PAST_CONFIRMATION_DELAY = timedelta(minutes=10)
SERVICE_INSTANCE_SLEEP = (
"odoo.addons.maintenance_service_http_monitoring.models.service_instance.time.sleep"
)
def _mock_response(status_code):
@@ -41,13 +41,6 @@ class TestHttpMonitoring(TransactionCase):
}
)
def _backdate_first_ko(self, *service_instances):
"""Simulate a KO streak old enough ago to be confirmed."""
for service_instance in service_instances:
service_instance.write(
{"http_first_ko_at": fields.Datetime.now() - PAST_CONFIRMATION_DELAY}
)
# ------------------------------------------------------------------
# Test 1 -- HTTP 200 -> service marked OK
# ------------------------------------------------------------------
@@ -62,26 +55,19 @@ class TestHttpMonitoring(TransactionCase):
self.assertIsNotNone(self.service_instance.last_http_check_date)
# ------------------------------------------------------------------
# Test 2 -- KO confirmed only once continuously KO for HTTP_KO_CONFIRMATION_DELAY,
# not on the first observed failure
# Test 2 -- Two KO passes -> maintenance.request created on the service
# ------------------------------------------------------------------
def test_http_500_creates_request_after_confirmation_delay(self):
with patch(SERVICE_INSTANCE_REQUESTS) as mock_requests:
def test_http_500_creates_maintenance_request(self):
with (
patch(SERVICE_INSTANCE_REQUESTS) as mock_requests,
patch(SERVICE_INSTANCE_SLEEP),
):
mock_requests.get.return_value = _mock_response(500)
mock_requests.exceptions.RequestException = Exception
self.env["service.instance"].cron_check_http_services()
self.assertFalse(self.service_instance.http_status_ok)
self.assertEqual(self.service_instance.last_http_status_code, 500)
self.assertTrue(self.service_instance.http_first_ko_at)
self.assertFalse(self.service_instance.http_maintenance_request)
self._backdate_first_ko(self.service_instance)
with patch(SERVICE_INSTANCE_REQUESTS) as mock_requests:
mock_requests.get.return_value = _mock_response(500)
mock_requests.exceptions.RequestException = Exception
self.env["service.instance"].cron_confirm_http_ko_services()
request = self.service_instance.http_maintenance_request
self.assertTrue(request)
@@ -104,33 +90,28 @@ class TestHttpMonitoring(TransactionCase):
self.assertEqual(self.service_instance.last_http_status_code, -1)
# ------------------------------------------------------------------
# Test 4 -- Repeated failure after confirmation -> a single request, no duplicate
# Test 4 -- Two consecutive cron runs KO -> no duplicate request
# ------------------------------------------------------------------
def test_no_duplicate_request_on_repeated_failure(self):
with patch(SERVICE_INSTANCE_REQUESTS) as mock_requests:
with (
patch(SERVICE_INSTANCE_REQUESTS) as mock_requests,
patch(SERVICE_INSTANCE_SLEEP),
):
mock_requests.get.return_value = _mock_response(500)
mock_requests.exceptions.RequestException = Exception
self.env["service.instance"].cron_check_http_services() # first_ko_at set
self.assertFalse(self.service_instance.http_maintenance_request)
self._backdate_first_ko(self.service_instance)
with patch(SERVICE_INSTANCE_REQUESTS) as mock_requests:
mock_requests.get.return_value = _mock_response(500)
mock_requests.exceptions.RequestException = Exception
# confirmed -> request created
self.env["service.instance"].cron_confirm_http_ko_services()
self.env["service.instance"].cron_check_http_services()
request_1 = self.service_instance.http_maintenance_request
self.assertTrue(request_1)
with patch(SERVICE_INSTANCE_REQUESTS) as mock_requests:
with (
patch(SERVICE_INSTANCE_REQUESTS) as mock_requests,
patch(SERVICE_INSTANCE_SLEEP),
):
mock_requests.get.return_value = _mock_response(500)
mock_requests.exceptions.RequestException = Exception
# already handled -> skipped
self.env["service.instance"].cron_confirm_http_ko_services()
self.env["service.instance"].cron_check_http_services()
# Service already has an open request -> the confirmation cron skips it
mock_requests.get.assert_not_called()
self.assertEqual(self.service_instance.http_maintenance_request, request_1)
self.assertEqual(
self.env["maintenance.request"].search_count(
@@ -200,8 +181,7 @@ class TestHttpMonitoring(TransactionCase):
self.assertEqual(self.service_instance.last_http_status_code, 404)
# ------------------------------------------------------------------
# Test 9 -- Webhook called only once the request is actually created
# (after confirmation delay), not on the first observed failure
# Test 9 -- Webhook called when a new maintenance.request is created
# ------------------------------------------------------------------
def test_webhook_called_on_new_request(self):
self.env["ir.config_parameter"].sudo().set_param(
@@ -210,23 +190,13 @@ class TestHttpMonitoring(TransactionCase):
)
with (
patch(SERVICE_INSTANCE_REQUESTS) as mock_requests,
patch(SERVICE_INSTANCE_SLEEP),
patch(EQUIPMENT_HTTP_REQUESTS) as mock_http,
):
mock_requests.get.return_value = _mock_response(500)
mock_requests.exceptions.RequestException = Exception
self.env["service.instance"].cron_check_http_services()
mock_http.post.assert_not_called()
self._backdate_first_ko(self.service_instance)
with (
patch(SERVICE_INSTANCE_REQUESTS) as mock_requests,
patch(EQUIPMENT_HTTP_REQUESTS) as mock_http,
):
mock_requests.get.return_value = _mock_response(500)
mock_requests.exceptions.RequestException = Exception
self.env["service.instance"].cron_confirm_http_ko_services()
mock_http.post.assert_called_once()
call_kwargs = mock_http.post.call_args
payload = call_kwargs.kwargs.get("json") or call_kwargs[1].get("json")
@@ -239,22 +209,15 @@ class TestHttpMonitoring(TransactionCase):
self.env["ir.config_parameter"].sudo().set_param(
"maintenance_service_http_monitoring.webhook_url", ""
)
with patch(SERVICE_INSTANCE_REQUESTS) as mock_requests:
mock_requests.get.return_value = _mock_response(500)
mock_requests.exceptions.RequestException = Exception
self.env["service.instance"].cron_check_http_services()
self._backdate_first_ko(self.service_instance)
with (
patch(SERVICE_INSTANCE_REQUESTS) as mock_requests,
patch(SERVICE_INSTANCE_SLEEP),
patch(EQUIPMENT_HTTP_REQUESTS) as mock_http,
):
mock_requests.get.return_value = _mock_response(500)
mock_requests.exceptions.RequestException = Exception
self.env["service.instance"].cron_confirm_http_ko_services()
self.env["service.instance"].cron_check_http_services()
self.assertTrue(self.service_instance.http_maintenance_request)
mock_http.post.assert_not_called()
# ------------------------------------------------------------------
@@ -272,25 +235,22 @@ class TestHttpMonitoring(TransactionCase):
self.assertFalse(self.service_instance.last_http_check_date)
# ------------------------------------------------------------------
# Test 12 -- Transient failure (KO, then back OK before confirmation) ->
# no request created, and the KO streak is reset
# Test 12 -- Transient failure (KO pass 1, OK pass 2) -> no request created
# ------------------------------------------------------------------
def test_transient_failure_no_request_created(self):
with patch(SERVICE_INSTANCE_REQUESTS) as mock_requests:
mock_requests.get.return_value = _mock_response(500)
with (
patch(SERVICE_INSTANCE_REQUESTS) as mock_requests,
patch(SERVICE_INSTANCE_SLEEP),
):
mock_requests.get.side_effect = [
_mock_response(500), # pass 1: KO
_mock_response(200), # pass 2 (retry): OK
]
mock_requests.exceptions.RequestException = Exception
self.env["service.instance"].cron_check_http_services()
self.assertTrue(self.service_instance.http_first_ko_at)
with patch(SERVICE_INSTANCE_REQUESTS) as mock_requests:
mock_requests.get.return_value = _mock_response(200)
mock_requests.exceptions.RequestException = Exception
self.env["service.instance"].cron_confirm_http_ko_services()
self.assertTrue(self.service_instance.http_status_ok)
self.assertEqual(self.service_instance.last_http_status_code, 200)
self.assertFalse(self.service_instance.http_first_ko_at)
self.assertFalse(self.service_instance.http_maintenance_request)
self.assertEqual(
self.env["maintenance.request"].search_count(
@@ -300,33 +260,25 @@ class TestHttpMonitoring(TransactionCase):
)
# ------------------------------------------------------------------
# Test 13 -- Confirmed failure (KO continuously past the confirmation delay)
# -> request created
# Test 13 -- Confirmed failure (KO pass 1 and 2) -> request created
# ------------------------------------------------------------------
def test_confirmed_failure_creates_request(self):
with patch(SERVICE_INSTANCE_REQUESTS) as mock_requests:
with (
patch(SERVICE_INSTANCE_REQUESTS) as mock_requests,
patch(SERVICE_INSTANCE_SLEEP) as mock_sleep,
):
mock_requests.get.return_value = _mock_response(503)
mock_requests.exceptions.RequestException = Exception
self.env["service.instance"].cron_check_http_services()
self.assertEqual(mock_requests.get.call_count, 1)
self.assertFalse(self.service_instance.http_maintenance_request)
self._backdate_first_ko(self.service_instance)
with patch(SERVICE_INSTANCE_REQUESTS) as mock_requests:
mock_requests.get.return_value = _mock_response(503)
mock_requests.exceptions.RequestException = Exception
self.env["service.instance"].cron_confirm_http_ko_services()
self.assertEqual(mock_requests.get.call_count, 1)
mock_sleep.assert_called_once_with(2)
self.assertEqual(mock_requests.get.call_count, 2)
self.assertFalse(self.service_instance.http_status_ok)
self.assertEqual(self.service_instance.last_http_status_code, 503)
self.assertTrue(self.service_instance.http_maintenance_request)
# ------------------------------------------------------------------
# Test 14 -- 2 KO services on same equipment -> 2 distinct requests
# once both reach the confirmation delay
# ------------------------------------------------------------------
def test_two_ko_services_same_equipment_create_two_requests(self):
service2 = self.env["service"].create({"name": "Test Service 2"})
@@ -338,18 +290,14 @@ class TestHttpMonitoring(TransactionCase):
}
)
with patch(SERVICE_INSTANCE_REQUESTS) as mock_requests:
with (
patch(SERVICE_INSTANCE_REQUESTS) as mock_requests,
patch(SERVICE_INSTANCE_SLEEP),
):
mock_requests.get.return_value = _mock_response(500)
mock_requests.exceptions.RequestException = Exception
self.env["service.instance"].cron_check_http_services()
self._backdate_first_ko(self.service_instance, service_instance2)
with patch(SERVICE_INSTANCE_REQUESTS) as mock_requests:
mock_requests.get.return_value = _mock_response(500)
mock_requests.exceptions.RequestException = Exception
self.env["service.instance"].cron_confirm_http_ko_services()
req1 = self.service_instance.http_maintenance_request
req2 = service_instance2.http_maintenance_request
@@ -369,26 +317,24 @@ class TestHttpMonitoring(TransactionCase):
# Test 15 -- Service recovery closes the open request and posts a note
# ------------------------------------------------------------------
def test_service_recovery_closes_request(self):
# First cron run: service is KO, streak just started -> no request yet
with patch(SERVICE_INSTANCE_REQUESTS) as mock_requests:
# First cron run: service is KO -> request created
with (
patch(SERVICE_INSTANCE_REQUESTS) as mock_requests,
patch(SERVICE_INSTANCE_SLEEP),
):
mock_requests.get.return_value = _mock_response(500)
mock_requests.exceptions.RequestException = Exception
self.env["service.instance"].cron_check_http_services()
self._backdate_first_ko(self.service_instance)
# Confirmation cron run: streak confirmed -> request created
with patch(SERVICE_INSTANCE_REQUESTS) as mock_requests:
mock_requests.get.return_value = _mock_response(500)
mock_requests.exceptions.RequestException = Exception
self.env["service.instance"].cron_confirm_http_ko_services()
request = self.service_instance.http_maintenance_request
self.assertTrue(request)
self.assertFalse(request.stage_id.done)
# Next cron run: service is back OK -> request auto-closed
with patch(SERVICE_INSTANCE_REQUESTS) as mock_requests:
# Second cron run: service is back OK -> request auto-closed
with (
patch(SERVICE_INSTANCE_REQUESTS) as mock_requests,
patch(SERVICE_INSTANCE_SLEEP),
):
mock_requests.get.return_value = _mock_response(200)
mock_requests.exceptions.RequestException = Exception
self.env["service.instance"].cron_check_http_services()
@@ -397,8 +343,6 @@ class TestHttpMonitoring(TransactionCase):
self.assertTrue(request.stage_id.done)
# http_maintenance_request must be cleared on the service instance
self.assertFalse(self.service_instance.http_maintenance_request)
# KO streak must be reset
self.assertFalse(self.service_instance.http_first_ko_at)
# A chatter note must have been posted mentioning the service URL
notes = request.message_ids.filtered(
lambda m: self.service_instance.service_url in (m.body or "")
@@ -414,55 +358,3 @@ class TestHttpMonitoring(TransactionCase):
# Calling close directly must not raise
self.service_instance._close_http_maintenance_request()
self.assertFalse(self.service_instance.http_maintenance_request)
# ------------------------------------------------------------------
# Test 17 -- Confirmation cron ignores services without a KO streak
# ------------------------------------------------------------------
def test_confirmation_cron_ignores_unflagged_services(self):
with patch(SERVICE_INSTANCE_REQUESTS) as mock_requests:
mock_requests.get.return_value = _mock_response(200)
mock_requests.exceptions.RequestException = Exception
self.env["service.instance"].cron_confirm_http_ko_services()
mock_requests.get.assert_not_called()
self.assertFalse(self.service_instance.http_maintenance_request)
# ------------------------------------------------------------------
# Test 18 -- Confirmation cron does not create a request before
# HTTP_KO_CONFIRMATION_DELAY has elapsed
# ------------------------------------------------------------------
def test_confirmation_cron_waits_for_confirmation_delay(self):
with patch(SERVICE_INSTANCE_REQUESTS) as mock_requests:
mock_requests.get.return_value = _mock_response(500)
mock_requests.exceptions.RequestException = Exception
self.env["service.instance"].cron_check_http_services()
self.assertTrue(self.service_instance.http_first_ko_at)
with patch(SERVICE_INSTANCE_REQUESTS) as mock_requests:
mock_requests.get.return_value = _mock_response(500)
mock_requests.exceptions.RequestException = Exception
self.env["service.instance"].cron_confirm_http_ko_services()
self.assertFalse(self.service_instance.http_maintenance_request)
# ------------------------------------------------------------------
# Test 19 -- Confirmation cron ignores services whose equipment is in
# maintenance mode
# ------------------------------------------------------------------
def test_confirmation_cron_skips_maintenance_mode(self):
with patch(SERVICE_INSTANCE_REQUESTS) as mock_requests:
mock_requests.get.return_value = _mock_response(500)
mock_requests.exceptions.RequestException = Exception
self.env["service.instance"].cron_check_http_services()
self.assertTrue(self.service_instance.http_first_ko_at)
self.equipment.write({"maintenance_mode": True})
with patch(SERVICE_INSTANCE_REQUESTS) as mock_requests:
mock_requests.get.return_value = _mock_response(500)
mock_requests.exceptions.RequestException = Exception
self.env["service.instance"].cron_confirm_http_ko_services()
mock_requests.get.assert_not_called()
self.assertFalse(self.service_instance.http_maintenance_request)

View File

@@ -18,7 +18,6 @@
<field name="last_http_status_code" />
<field name="http_status_ok" />
<field name="http_maintenance_request" optional="hide" />
<field name="http_first_ko_at" optional="hide" />
</field>
</field>
</record>

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>

View File

@@ -1,14 +0,0 @@
/** @type {import('prettier').Config} */
const config = {
// https://github.com/prettier/prettier/issues/15388#issuecomment-1717746872
plugins: [require.resolve("@prettier/plugin-xml")],
bracketSpacing: false,
printWidth: 88,
proseWrap: "always",
semi: true,
trailingComma: "es5",
xmlWhitespaceSensitivity: "preserve",
};
module.exports = config;