Compare commits
15 Commits
fd9b169925
...
update-ser
| Author | SHA1 | Date | |
|---|---|---|---|
| e48a3443f1 | |||
|
|
6e19575012 | ||
|
|
ae5977ef81 | ||
|
|
4581b3d019 | ||
|
|
bb6f12945f | ||
|
|
c4d7e9b8a9 | ||
|
|
c238e54808 | ||
|
|
2724d29f25 | ||
|
|
b9b8662bad | ||
|
|
cb3ed485b8 | ||
|
|
959374f75f | ||
|
|
da0cbab39b | ||
|
|
3bf8ccfb61 | ||
|
|
1f9a0996c0 | ||
|
|
d0c23d9246 |
92
maintenance_create_requests_from_project_task/README.md
Normal file
92
maintenance_create_requests_from_project_task/README.md
Normal file
@@ -0,0 +1,92 @@
|
|||||||
|
============================================
|
||||||
|
maintenance_create_requests_from_project_task
|
||||||
|
============================================
|
||||||
|
|
||||||
|
This module allows the bulk creation of maintenance requests directly from a
|
||||||
|
project task. It is particularly useful when a task requires maintenance
|
||||||
|
actions on multiple equipment items simultaneously.
|
||||||
|
|
||||||
|
Key features:
|
||||||
|
|
||||||
|
- **Bulk creation**: Create multiple maintenance requests at once from a task
|
||||||
|
- **Equipment filtering**: Use domain filters to select target equipment
|
||||||
|
- **Smart defaults**: Pre-fills equipment from the task's project
|
||||||
|
- **Request tracking**: View all maintenance requests linked to a task
|
||||||
|
|
||||||
|
# Installation
|
||||||
|
|
||||||
|
Use Odoo normal module installation procedure to install
|
||||||
|
`maintenance_create_requests_from_project_task`.
|
||||||
|
|
||||||
|
This module depends on:
|
||||||
|
- `maintenance`
|
||||||
|
- `maintenance_project`
|
||||||
|
- `project`
|
||||||
|
|
||||||
|
# Configuration
|
||||||
|
|
||||||
|
No specific configuration is required.
|
||||||
|
|
||||||
|
# Usage
|
||||||
|
|
||||||
|
## Creating Maintenance Requests from a Task
|
||||||
|
|
||||||
|
1. Go to Project > Tasks
|
||||||
|
2. Open a task
|
||||||
|
3. In the action menu (or via the server action), click "Create maintenance requests"
|
||||||
|
4. A wizard opens with:
|
||||||
|
- **Task**: The source task (read-only)
|
||||||
|
- **Title**: The name for all created maintenance requests
|
||||||
|
- **Equipment Domain**: Filter to select which equipment to target
|
||||||
|
- By default, shows equipment linked to the task's project
|
||||||
|
- Use the domain builder to refine the selection
|
||||||
|
- **Technician**: Assign a technician to all requests
|
||||||
|
- **Maintenance Type**: Corrective or Preventive
|
||||||
|
- **Priority**: From Very Low to High
|
||||||
|
- **Duration**: Estimated duration in hours
|
||||||
|
- **Scheduled Date**: When the maintenance should occur
|
||||||
|
- **Description**: Details about the maintenance work
|
||||||
|
5. Click "Create"
|
||||||
|
6. All matching equipment will have a maintenance request created
|
||||||
|
7. You are redirected to the list of created requests
|
||||||
|
|
||||||
|
## Viewing Linked Maintenance Requests
|
||||||
|
|
||||||
|
On the task form:
|
||||||
|
- A smart button shows the count of open (not done) maintenance requests
|
||||||
|
- Click it to view all maintenance requests linked to this task
|
||||||
|
|
||||||
|
## Equipment Domain Examples
|
||||||
|
|
||||||
|
- All equipment in the project: `[('project_id', '=', project_id)]`
|
||||||
|
- Only servers: `[('category_id.name', '=', 'Server')]`
|
||||||
|
- Equipment needing backup: `[('backup_activated', '=', True)]`
|
||||||
|
- Combine conditions: `[('project_id', '=', project_id), ('category_id.name', '=', 'Server')]`
|
||||||
|
|
||||||
|
# Known issues / Roadmap
|
||||||
|
|
||||||
|
- Add template support for common maintenance scenarios
|
||||||
|
- Add option to create a single request for multiple equipment
|
||||||
|
|
||||||
|
# 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,48 +0,0 @@
|
|||||||
=============================================
|
|
||||||
maintenance_create_requests_from_project_task
|
|
||||||
=============================================
|
|
||||||
|
|
||||||
Allow the creation of multiple maintenance requests from a projet task.
|
|
||||||
|
|
||||||
When user click on the button "Create maintenance requests", a wizard appears.
|
|
||||||
The wizard allows the user to configure the requests and to select the maintenance equipments concerned.
|
|
||||||
At wizard validation, one or several maintenance requests are created, one for each equipement selected.
|
|
||||||
|
|
||||||
Installation
|
|
||||||
============
|
|
||||||
|
|
||||||
Use Odoo normal module installation procedure to install
|
|
||||||
``maintenance_create_requests_from_project_task``.
|
|
||||||
|
|
||||||
Known issues / Roadmap
|
|
||||||
======================
|
|
||||||
|
|
||||||
None yet.
|
|
||||||
|
|
||||||
Bug Tracker
|
|
||||||
===========
|
|
||||||
|
|
||||||
Bugs are tracked on `our issues website <https://github.com/elabore-coop/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.
|
|
||||||
@@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
{
|
{
|
||||||
"name": "maintenance_create_requests_from_project_task",
|
"name": "maintenance_create_requests_from_project_task",
|
||||||
"version": "16.0.1.0.0",
|
"version": "18.0.1.0.0",
|
||||||
"author": "Elabore",
|
"author": "Elabore",
|
||||||
"website": "https://elabore.coop",
|
"website": "https://elabore.coop",
|
||||||
"maintainer": "Stéphan Sainléger",
|
"maintainer": "Stéphan Sainléger",
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
<button
|
<button
|
||||||
name="action_view_maintenance_request_ids"
|
name="action_view_maintenance_request_ids"
|
||||||
type="object"
|
type="object"
|
||||||
attrs="{'invisible': [('maintenance_request_count', '=', 0)]}"
|
invisible="maintenance_request_count == 0"
|
||||||
class="oe_stat_button"
|
class="oe_stat_button"
|
||||||
icon="fa-tasks"
|
icon="fa-tasks"
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
from odoo import _, api, fields, models
|
from odoo import _, api, fields, models
|
||||||
|
from odoo.exceptions import UserError
|
||||||
from odoo.tools.safe_eval import safe_eval
|
from odoo.tools.safe_eval import safe_eval
|
||||||
|
|
||||||
|
|
||||||
@@ -77,7 +78,10 @@ class CreateMaintenanceRequestsWizard(models.TransientModel):
|
|||||||
)
|
)
|
||||||
if len(equipment_list) == 0:
|
if len(equipment_list) == 0:
|
||||||
raise UserError(
|
raise UserError(
|
||||||
"No equipment is matching the domain. Maintenance request creation is not possible."
|
_(
|
||||||
|
"No equipment is matching the domain. "
|
||||||
|
"Maintenance request creation is not possible."
|
||||||
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
vals_list = []
|
vals_list = []
|
||||||
@@ -104,7 +108,7 @@ class CreateMaintenanceRequestsWizard(models.TransientModel):
|
|||||||
|
|
||||||
def _get_action(self, maintenance_requests):
|
def _get_action(self, maintenance_requests):
|
||||||
"""
|
"""
|
||||||
Provide the action to go to the tree view of the maintenance requests created.
|
Provide the action to go to the list view of the maintenance requests created.
|
||||||
"""
|
"""
|
||||||
search_view_ref = self.env.ref(
|
search_view_ref = self.env.ref(
|
||||||
"maintenance.hr_equipment_request_view_search", False
|
"maintenance.hr_equipment_request_view_search", False
|
||||||
@@ -112,7 +116,7 @@ class CreateMaintenanceRequestsWizard(models.TransientModel):
|
|||||||
form_view_ref = self.env.ref(
|
form_view_ref = self.env.ref(
|
||||||
"maintenance.hr_equipment_request_view_form", False
|
"maintenance.hr_equipment_request_view_form", False
|
||||||
)
|
)
|
||||||
tree_view_ref = self.env.ref(
|
list_view_ref = self.env.ref(
|
||||||
"maintenance.hr_equipment_request_view_tree", False
|
"maintenance.hr_equipment_request_view_tree", False
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -121,6 +125,6 @@ class CreateMaintenanceRequestsWizard(models.TransientModel):
|
|||||||
"name": "Maintenance Requests",
|
"name": "Maintenance Requests",
|
||||||
"res_model": "maintenance.request",
|
"res_model": "maintenance.request",
|
||||||
"type": "ir.actions.act_window",
|
"type": "ir.actions.act_window",
|
||||||
"views": [(tree_view_ref.id, "tree"), (form_view_ref.id, "form")],
|
"views": [(list_view_ref.id, "list"), (form_view_ref.id, "form")],
|
||||||
"search_view_id": search_view_ref and [search_view_ref.id],
|
"search_view_id": search_view_ref and [search_view_ref.id],
|
||||||
}
|
}
|
||||||
|
|||||||
89
maintenance_server_data/README.md
Normal file
89
maintenance_server_data/README.md
Normal file
@@ -0,0 +1,89 @@
|
|||||||
|
=======================
|
||||||
|
maintenance_server_data
|
||||||
|
=======================
|
||||||
|
|
||||||
|
This module extends the maintenance equipment model to store detailed server
|
||||||
|
information, enabling comprehensive server infrastructure management within Odoo.
|
||||||
|
|
||||||
|
It adds several new models and fields to track:
|
||||||
|
|
||||||
|
- **Server specifications**: IP address, CPU cores, RAM, disk storage
|
||||||
|
- **Operating system**: Distribution name and version
|
||||||
|
- **Services**: Track services running on each server with their versions and URLs
|
||||||
|
- **Backup information**: Backup server, activation status, and health
|
||||||
|
|
||||||
|
# Installation
|
||||||
|
|
||||||
|
Use Odoo normal module installation procedure to install
|
||||||
|
`maintenance_server_data`.
|
||||||
|
|
||||||
|
This module depends on `maintenance`.
|
||||||
|
|
||||||
|
# Configuration
|
||||||
|
|
||||||
|
No specific configuration is required. After installation, new fields will be
|
||||||
|
available on the maintenance equipment form.
|
||||||
|
|
||||||
|
# Usage
|
||||||
|
|
||||||
|
## Managing Server Equipment
|
||||||
|
|
||||||
|
1. Go to Maintenance > Equipments
|
||||||
|
2. Create or edit an equipment record
|
||||||
|
3. Fill in the server-specific fields:
|
||||||
|
- **Server IP Address**: The server's IP address
|
||||||
|
- **Distribution**: Select or create an OS distribution
|
||||||
|
- **Hosting City**: Physical location of the server
|
||||||
|
- **Nb Cores**: Number of CPU cores
|
||||||
|
- **RAM (Go)**: Amount of RAM in gigabytes
|
||||||
|
- **Disk Storage (Go)**: Disk capacity in gigabytes
|
||||||
|
- **Backup Activated**: Whether backups are enabled
|
||||||
|
- **Backup Server**: The backup destination server
|
||||||
|
- **Backup OK**: Current backup health status
|
||||||
|
|
||||||
|
## Managing OS Distributions
|
||||||
|
|
||||||
|
1. Go to Maintenance > Configuration > OS Distributions
|
||||||
|
2. Create distributions with name and version (e.g., "Ubuntu", "22.04")
|
||||||
|
3. The display name is automatically computed from name + version
|
||||||
|
|
||||||
|
## Managing Services
|
||||||
|
|
||||||
|
1. Go to Maintenance > Configuration > Services
|
||||||
|
2. Create service definitions (e.g., "PostgreSQL", "Nginx", "Odoo")
|
||||||
|
3. Create service versions for each service
|
||||||
|
4. Mark the latest version with "Is Last Version?"
|
||||||
|
|
||||||
|
## Managing Service Instances
|
||||||
|
|
||||||
|
1. Go to Maintenance > Configuration > Service Instances
|
||||||
|
2. Link services to equipment with their specific version and URL
|
||||||
|
3. Service instances are automatically archived when their equipment is archived
|
||||||
|
|
||||||
|
# Known issues / Roadmap
|
||||||
|
|
||||||
|
- Add monitoring integration for automated backup status checks
|
||||||
|
- Add service version upgrade tracking
|
||||||
|
|
||||||
|
# Bug Tracker
|
||||||
|
|
||||||
|
Bugs are tracked on
|
||||||
|
[our issues website](https://github.com/elabore-coop/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,44 +0,0 @@
|
|||||||
======================================
|
|
||||||
maintenance_server_data
|
|
||||||
======================================
|
|
||||||
|
|
||||||
Gather several identification data about the servers to maintain.
|
|
||||||
|
|
||||||
Installation
|
|
||||||
============
|
|
||||||
|
|
||||||
Use Odoo normal module installation procedure to install
|
|
||||||
``maintenance_server_data``.
|
|
||||||
|
|
||||||
Known issues / Roadmap
|
|
||||||
======================
|
|
||||||
|
|
||||||
None yet.
|
|
||||||
|
|
||||||
Bug Tracker
|
|
||||||
===========
|
|
||||||
|
|
||||||
Bugs are tracked on `our issues website <https://github.com/elabore-coop/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.
|
|
||||||
@@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
{
|
{
|
||||||
"name": "maintenance_server_data",
|
"name": "maintenance_server_data",
|
||||||
"version": "16.0.1.0.0",
|
"version": "18.0.1.0.0",
|
||||||
"author": "Elabore",
|
"author": "Elabore",
|
||||||
"website": "https://git.elabore.coop/elabore/maintenance-tools",
|
"website": "https://git.elabore.coop/elabore/maintenance-tools",
|
||||||
"maintainer": "Stéphan Sainléger",
|
"maintainer": "Stéphan Sainléger",
|
||||||
|
|||||||
@@ -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" />
|
||||||
@@ -23,14 +24,14 @@
|
|||||||
<xpath expr="//notebook" position="inside">
|
<xpath expr="//notebook" position="inside">
|
||||||
<page name="services" string="Services">
|
<page name="services" string="Services">
|
||||||
<field name="service_ids" nolabel="1">
|
<field name="service_ids" nolabel="1">
|
||||||
<tree create="true" delete="true" editable="top">
|
<list create="true" delete="true" editable="top">
|
||||||
<field name="service_id" />
|
<field name="service_id" />
|
||||||
<field
|
<field
|
||||||
name="version_id"
|
name="version_id"
|
||||||
domain="[('service_id', '=', service_id)]"
|
domain="[('service_id', '=', service_id)]"
|
||||||
/>
|
/>
|
||||||
<field name="service_url" />
|
<field name="service_url" />
|
||||||
</tree>
|
</list>
|
||||||
</field>
|
</field>
|
||||||
</page>
|
</page>
|
||||||
</xpath>
|
</xpath>
|
||||||
@@ -39,12 +40,13 @@
|
|||||||
|
|
||||||
|
|
||||||
<record id="equipment_view_tree_server_inherit" model="ir.ui.view">
|
<record id="equipment_view_tree_server_inherit" model="ir.ui.view">
|
||||||
<field name="name">equipment.tree.server.inherit</field>
|
<field name="name">equipment.list.server.inherit</field>
|
||||||
<field name="model">maintenance.equipment</field>
|
<field name="model">maintenance.equipment</field>
|
||||||
<field name="inherit_id" ref="maintenance.hr_equipment_view_tree" />
|
<field name="inherit_id" ref="maintenance.hr_equipment_view_tree" />
|
||||||
<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" />
|
||||||
|
|||||||
@@ -1,20 +1,20 @@
|
|||||||
<?xml version="1.0" encoding="utf-8" ?>
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
<odoo>
|
<odoo>
|
||||||
<record id="os_distribution_view_tree" model="ir.ui.view">
|
<record id="os_distribution_view_tree" model="ir.ui.view">
|
||||||
<field name="name">os.distribution.view.tree</field>
|
<field name="name">os.distribution.view.list</field>
|
||||||
<field name="model">os.distribution</field>
|
<field name="model">os.distribution</field>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<tree string="OS Distributions" editable="top">
|
<list editable="top">
|
||||||
<field name="distrib_name" />
|
<field name="distrib_name" />
|
||||||
<field name="distrib_version" />
|
<field name="distrib_version" />
|
||||||
</tree>
|
</list>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
<record id="os_distribution_action" model="ir.actions.act_window">
|
<record id="os_distribution_action" model="ir.actions.act_window">
|
||||||
<field name="name">OS Distribution</field>
|
<field name="name">OS Distribution</field>
|
||||||
<field name="res_model">os.distribution</field>
|
<field name="res_model">os.distribution</field>
|
||||||
<field name="view_mode">tree</field>
|
<field name="view_mode">list</field>
|
||||||
<field name="view_id" ref="os_distribution_view_tree" />
|
<field name="view_id" ref="os_distribution_view_tree" />
|
||||||
<field name="help" type="html">
|
<field name="help" type="html">
|
||||||
<p class="o_view_nocontent_smiling_face">
|
<p class="o_view_nocontent_smiling_face">
|
||||||
|
|||||||
@@ -2,46 +2,46 @@
|
|||||||
<odoo>
|
<odoo>
|
||||||
<!-- VIEWS -->
|
<!-- VIEWS -->
|
||||||
<record id="service_view_tree" model="ir.ui.view">
|
<record id="service_view_tree" model="ir.ui.view">
|
||||||
<field name="name">service.view.tree</field>
|
<field name="name">service.view.list</field>
|
||||||
<field name="model">service</field>
|
<field name="model">service</field>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<tree string="Services" editable="top">
|
<list editable="top">
|
||||||
<field name="name" />
|
<field name="name" />
|
||||||
</tree>
|
</list>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
<record id="service_version_view_tree" model="ir.ui.view">
|
<record id="service_version_view_tree" model="ir.ui.view">
|
||||||
<field name="name">service.version.view.tree</field>
|
<field name="name">service.version.view.list</field>
|
||||||
<field name="model">service.version</field>
|
<field name="model">service.version</field>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<tree string="Service versions" editable="top">
|
<list editable="top">
|
||||||
<field name="service_id" />
|
<field name="service_id" />
|
||||||
<field name="name" />
|
<field name="name" />
|
||||||
<field name="is_last_version" />
|
<field name="is_last_version" />
|
||||||
</tree>
|
</list>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
<record id="backup_server_view_tree" model="ir.ui.view">
|
<record id="backup_server_view_tree" model="ir.ui.view">
|
||||||
<field name="name">backup.server.view.tree</field>
|
<field name="name">backup.server.view.list</field>
|
||||||
<field name="model">backup.server</field>
|
<field name="model">backup.server</field>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<tree string="Backup Servers" editable="top">
|
<list editable="top">
|
||||||
<field name="name" />
|
<field name="name" />
|
||||||
</tree>
|
</list>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
<record id="service_instance_view_tree" model="ir.ui.view">
|
<record id="service_instance_view_tree" model="ir.ui.view">
|
||||||
<field name="name">service.instance.view.tree</field>
|
<field name="name">service.instance.view.list</field>
|
||||||
<field name="model">service.instance</field>
|
<field name="model">service.instance</field>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<tree>
|
<list>
|
||||||
<field name="equipment_id" />
|
<field name="equipment_id" />
|
||||||
<field name="service_id" />
|
<field name="service_id" />
|
||||||
<field name="version_id" />
|
<field name="version_id" />
|
||||||
</tree>
|
</list>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
@@ -86,7 +86,7 @@
|
|||||||
<record id="service_action" model="ir.actions.act_window">
|
<record id="service_action" model="ir.actions.act_window">
|
||||||
<field name="name">Service</field>
|
<field name="name">Service</field>
|
||||||
<field name="res_model">service</field>
|
<field name="res_model">service</field>
|
||||||
<field name="view_mode">tree</field>
|
<field name="view_mode">list</field>
|
||||||
<field name="view_id" ref="service_view_tree" />
|
<field name="view_id" ref="service_view_tree" />
|
||||||
<field name="help" type="html">
|
<field name="help" type="html">
|
||||||
<p class="o_view_nocontent_smiling_face">
|
<p class="o_view_nocontent_smiling_face">
|
||||||
@@ -98,7 +98,7 @@
|
|||||||
<record id="service_version_action" model="ir.actions.act_window">
|
<record id="service_version_action" model="ir.actions.act_window">
|
||||||
<field name="name">Service Version</field>
|
<field name="name">Service Version</field>
|
||||||
<field name="res_model">service.version</field>
|
<field name="res_model">service.version</field>
|
||||||
<field name="view_mode">tree</field>
|
<field name="view_mode">list</field>
|
||||||
<field name="view_id" ref="service_version_view_tree" />
|
<field name="view_id" ref="service_version_view_tree" />
|
||||||
<field name="help" type="html">
|
<field name="help" type="html">
|
||||||
<p class="o_view_nocontent_smiling_face">
|
<p class="o_view_nocontent_smiling_face">
|
||||||
@@ -110,7 +110,7 @@
|
|||||||
<record id="backup_server_action" model="ir.actions.act_window">
|
<record id="backup_server_action" model="ir.actions.act_window">
|
||||||
<field name="name">Backup server</field>
|
<field name="name">Backup server</field>
|
||||||
<field name="res_model">backup.server</field>
|
<field name="res_model">backup.server</field>
|
||||||
<field name="view_mode">tree</field>
|
<field name="view_mode">list</field>
|
||||||
<field name="view_id" ref="backup_server_view_tree" />
|
<field name="view_id" ref="backup_server_view_tree" />
|
||||||
<field name="help" type="html">
|
<field name="help" type="html">
|
||||||
<p class="o_view_nocontent_smiling_face">
|
<p class="o_view_nocontent_smiling_face">
|
||||||
@@ -122,7 +122,7 @@
|
|||||||
<record id="service_instance_action" model="ir.actions.act_window">
|
<record id="service_instance_action" model="ir.actions.act_window">
|
||||||
<field name="name">Services</field>
|
<field name="name">Services</field>
|
||||||
<field name="res_model">service.instance</field>
|
<field name="res_model">service.instance</field>
|
||||||
<field name="view_mode">tree</field>
|
<field name="view_mode">list</field>
|
||||||
<field name="view_id" ref="service_instance_view_tree" />
|
<field name="view_id" ref="service_instance_view_tree" />
|
||||||
<field name="help" type="html">
|
<field name="help" type="html">
|
||||||
<p class="o_view_nocontent_smiling_face">
|
<p class="o_view_nocontent_smiling_face">
|
||||||
|
|||||||
2
maintenance_service_http_monitoring/.gitignore
vendored
Normal file
2
maintenance_service_http_monitoring/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
*.*~
|
||||||
|
*pyc
|
||||||
161
maintenance_service_http_monitoring/README.md
Normal file
161
maintenance_service_http_monitoring/README.md
Normal file
@@ -0,0 +1,161 @@
|
|||||||
|
===================================
|
||||||
|
maintenance_service_http_monitoring
|
||||||
|
===================================
|
||||||
|
|
||||||
|
This module provides automated HTTP availability monitoring for services
|
||||||
|
defined on maintenance equipment. It periodically checks the HTTP status of
|
||||||
|
service URLs and automatically creates maintenance requests when services
|
||||||
|
are detected as unavailable.
|
||||||
|
|
||||||
|
Key features:
|
||||||
|
|
||||||
|
- **Automated HTTP checks**: Scheduled cron job checks all active services
|
||||||
|
- **Maintenance mode**: Temporarily disable monitoring during planned maintenance
|
||||||
|
- **Automatic maintenance requests**: Creates corrective maintenance requests
|
||||||
|
when services fail HTTP checks
|
||||||
|
- **Status tracking**: Records last HTTP status code and check date per service
|
||||||
|
|
||||||
|
# Installation
|
||||||
|
|
||||||
|
Use Odoo normal module installation procedure to install
|
||||||
|
`maintenance_service_http_monitoring`.
|
||||||
|
|
||||||
|
This module depends on:
|
||||||
|
- `maintenance`
|
||||||
|
- `maintenance_server_data`
|
||||||
|
|
||||||
|
**Python dependencies**: This module requires the `requests` library.
|
||||||
|
|
||||||
|
# Configuration
|
||||||
|
|
||||||
|
## Maintenance Mode Duration
|
||||||
|
|
||||||
|
By default, maintenance mode lasts 4 hours. To change this:
|
||||||
|
|
||||||
|
1. Go to Settings > Technical > System Parameters
|
||||||
|
2. Create or edit the parameter:
|
||||||
|
- Key: `maintenance_service_http_monitoring.maintenance_mode_duration`
|
||||||
|
- Value: Duration in hours (e.g., `8`)
|
||||||
|
|
||||||
|
## Cron Jobs
|
||||||
|
|
||||||
|
Two scheduled actions are installed:
|
||||||
|
|
||||||
|
1. **HTTP Service Monitoring: check all services**
|
||||||
|
- Runs every 15 minutes
|
||||||
|
- Checks HTTP status of all active service instances with URLs
|
||||||
|
|
||||||
|
2. **HTTP Service Monitoring: deactivate expired maintenance mode**
|
||||||
|
- Runs every 15 minutes
|
||||||
|
- Automatically disables maintenance mode when the end time is reached
|
||||||
|
|
||||||
|
## Webhook Notifications
|
||||||
|
|
||||||
|
Go to **Settings > Technical > Parameters > System Parameters** and configure:
|
||||||
|
|
||||||
|
+--------------------------------------------------------+----------------------------------------+
|
||||||
|
| Key | Description |
|
||||||
|
+========================================================+========================================+
|
||||||
|
| ``maintenance_service_http_monitoring.webhook_url`` | Webhook URL (POST endpoint) |
|
||||||
|
+--------------------------------------------------------+----------------------------------------+
|
||||||
|
| ``maintenance_service_http_monitoring.webhook_user`` | Basic Auth username (optional) |
|
||||||
|
+--------------------------------------------------------+----------------------------------------+
|
||||||
|
| ``maintenance_service_http_monitoring.webhook_password``| Basic Auth password (optional) |
|
||||||
|
+--------------------------------------------------------+----------------------------------------+
|
||||||
|
|
||||||
|
|
||||||
|
# Usage
|
||||||
|
|
||||||
|
## Monitoring Services
|
||||||
|
|
||||||
|
Services are automatically monitored if they have:
|
||||||
|
- A service URL defined
|
||||||
|
- An associated equipment
|
||||||
|
- The equipment is not in maintenance mode
|
||||||
|
- The service instance is active
|
||||||
|
|
||||||
|
The monitoring checks HTTPS availability (HTTP URLs are automatically
|
||||||
|
upgraded to HTTPS). A service is considered OK if it returns HTTP 200.
|
||||||
|
|
||||||
|
## Using Maintenance Mode
|
||||||
|
|
||||||
|
When performing planned maintenance on a server:
|
||||||
|
|
||||||
|
1. Go to Maintenance > Equipments
|
||||||
|
2. Open the equipment record
|
||||||
|
3. Click "Activer le mode maintenance" (Activate maintenance mode)
|
||||||
|
4. HTTP monitoring is suspended for this equipment
|
||||||
|
5. The mode automatically expires after the configured duration
|
||||||
|
6. Or click "Désactiver le mode maintenance" to end it manually
|
||||||
|
|
||||||
|
## Viewing HTTP Status
|
||||||
|
|
||||||
|
On service instances, you can see:
|
||||||
|
- **Last HTTP Status Code**: The last received HTTP status (200, 404, 500, etc.)
|
||||||
|
- **Last HTTP Check Date**: When the last check was performed
|
||||||
|
- **HTTP Status OK**: Quick visual indicator of service health
|
||||||
|
|
||||||
|
## Automatic Maintenance Requests
|
||||||
|
|
||||||
|
When a service fails HTTP checks:
|
||||||
|
- 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
|
||||||
|
- 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
|
||||||
|
- A chatter note is posted on the request by OdooBot to record the automatic closure
|
||||||
|
- The link between the service and the request is cleared, allowing a new request to
|
||||||
|
be created if the service fails again in the future
|
||||||
|
|
||||||
|
## Webhook notifications
|
||||||
|
|
||||||
|
When a new maintenance request is created (HTTP check failure), the module can
|
||||||
|
send a webhook notification to an external service (e.g., n8n, Rocket.Chat, Slack).
|
||||||
|
|
||||||
|
The webhook sends a JSON POST with the following structure::
|
||||||
|
|
||||||
|
{
|
||||||
|
"id": 42,
|
||||||
|
"name": "[HTTP KO] Server Name",
|
||||||
|
"priority": "2",
|
||||||
|
"description": "Service KO: https://example.com",
|
||||||
|
"equipment": "Server Name",
|
||||||
|
"link": "https://odoo.example.com/web#id=42&model=maintenance.request&view_type=form"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# Known issues / Roadmap
|
||||||
|
|
||||||
|
- Add configurable alert thresholds (e.g., alert after N consecutive failures)
|
||||||
|
- Add email/notification on service failure
|
||||||
|
- Support custom HTTP check endpoints (e.g., /health)
|
||||||
|
- Add support for basic authentication
|
||||||
|
|
||||||
|
# Bug Tracker
|
||||||
|
|
||||||
|
Bugs are tracked on
|
||||||
|
[our issues website](https://github.com/elabore-coop/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,58 +0,0 @@
|
|||||||
======================================
|
|
||||||
maintenance_service_http_monitoring
|
|
||||||
======================================
|
|
||||||
|
|
||||||
Module that allows monitoring of different services by checking their HTTP 200 responses:
|
|
||||||
|
|
||||||
- Uses the `maintenance_server_data` service for each device.
|
|
||||||
|
|
||||||
If the service has a URL, a request is made.
|
|
||||||
- Adds maintenance mode for a device:
|
|
||||||
|
|
||||||
- Allows disabling HTTP checks for a specified time (defined in the cron job).
|
|
||||||
|
|
||||||
## Logic:
|
|
||||||
If a request fails and a maintenance task has already been created for the same day,
|
|
||||||
no new task is added.
|
|
||||||
|
|
||||||
The default values for the cron jobs are located in `data/cron.xml`.
|
|
||||||
|
|
||||||
|
|
||||||
Installation
|
|
||||||
============
|
|
||||||
|
|
||||||
Use Odoo normal module installation procedure to install
|
|
||||||
``maintenance_service_http_monitoring``.
|
|
||||||
|
|
||||||
Known issues / Roadmap
|
|
||||||
======================
|
|
||||||
|
|
||||||
None yet.
|
|
||||||
|
|
||||||
Bug Tracker
|
|
||||||
===========
|
|
||||||
|
|
||||||
Bugs are tracked on `our issues website <https://github.com/elabore-coop/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
|
|
||||||
------------
|
|
||||||
|
|
||||||
* Boris Gallet
|
|
||||||
|
|
||||||
Funders
|
|
||||||
-------
|
|
||||||
|
|
||||||
The development of this module has been financially supported by:
|
|
||||||
* Elabore (https://elabore.coop)
|
|
||||||
|
|
||||||
|
|
||||||
Maintainer
|
|
||||||
----------
|
|
||||||
|
|
||||||
This module is maintained by Elabore.
|
|
||||||
@@ -1,13 +1,14 @@
|
|||||||
{
|
{
|
||||||
"name": "maintenance_service_http_monitoring",
|
"name": "maintenance_service_http_monitoring",
|
||||||
"version": "16.0.1.0.0",
|
"version": "18.0.1.0.0",
|
||||||
"author": "Elabore",
|
"author": "Elabore",
|
||||||
"license": "AGPL-3",
|
"license": "AGPL-3",
|
||||||
"category": "Tools",
|
"category": "Tools",
|
||||||
"summary": "Monitor HTTP availability of services",
|
"summary": "Monitor HTTP availability of services",
|
||||||
"depends": ["base", "maintenance", "maintenance_server_data"],
|
"depends": ["base", "maintenance", "base_maintenance", "hr_maintenance", "maintenance_server_data"],
|
||||||
"external_dependencies": {"python": ["requests"]},
|
"external_dependencies": {"python": ["requests"]},
|
||||||
"data": [
|
"data": [
|
||||||
|
"data/ir_config_parameter.xml",
|
||||||
"data/cron.xml",
|
"data/cron.xml",
|
||||||
"views/service_instance_views.xml",
|
"views/service_instance_views.xml",
|
||||||
"views/maintenance_equipment_views.xml",
|
"views/maintenance_equipment_views.xml",
|
||||||
|
|||||||
@@ -5,10 +5,8 @@
|
|||||||
<field name="model_id" ref="maintenance_server_data.model_service_instance" />
|
<field name="model_id" ref="maintenance_server_data.model_service_instance" />
|
||||||
<field name="state">code</field>
|
<field name="state">code</field>
|
||||||
<field name="code">model.cron_check_http_services()</field>
|
<field name="code">model.cron_check_http_services()</field>
|
||||||
<field name="interval_number">15</field>
|
<field name="interval_number">10</field>
|
||||||
<field name="interval_type">minutes</field>
|
<field name="interval_type">minutes</field>
|
||||||
<field name="numbercall">-1</field>
|
|
||||||
<field name="doall">False</field>
|
|
||||||
</record>
|
</record>
|
||||||
<record id="ir_cron_maintenance_mode_expiry" model="ir.cron">
|
<record id="ir_cron_maintenance_mode_expiry" model="ir.cron">
|
||||||
<field
|
<field
|
||||||
@@ -22,7 +20,5 @@
|
|||||||
<field name="code">model.cron_deactivate_expired_maintenance_mode()</field>
|
<field name="code">model.cron_deactivate_expired_maintenance_mode()</field>
|
||||||
<field name="interval_number">15</field>
|
<field name="interval_number">15</field>
|
||||||
<field name="interval_type">minutes</field>
|
<field name="interval_type">minutes</field>
|
||||||
<field name="numbercall">-1</field>
|
|
||||||
<field name="doall">False</field>
|
|
||||||
</record>
|
</record>
|
||||||
</odoo>
|
</odoo>
|
||||||
|
|||||||
@@ -0,0 +1,15 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<odoo noupdate="1">
|
||||||
|
<record id="config_param_webhook_url" model="ir.config_parameter">
|
||||||
|
<field name="key">maintenance_service_http_monitoring.webhook_url</field>
|
||||||
|
<field name="value"></field>
|
||||||
|
</record>
|
||||||
|
<record id="config_param_webhook_user" model="ir.config_parameter">
|
||||||
|
<field name="key">maintenance_service_http_monitoring.webhook_user</field>
|
||||||
|
<field name="value"></field>
|
||||||
|
</record>
|
||||||
|
<record id="config_param_webhook_password" model="ir.config_parameter">
|
||||||
|
<field name="key">maintenance_service_http_monitoring.webhook_password</field>
|
||||||
|
<field name="value"></field>
|
||||||
|
</record>
|
||||||
|
</odoo>
|
||||||
@@ -1,30 +1,32 @@
|
|||||||
|
import logging
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
|
|
||||||
from odoo import api, fields, models
|
from odoo import api, fields, models
|
||||||
|
|
||||||
|
try:
|
||||||
|
import requests as http_requests
|
||||||
|
except ImportError:
|
||||||
|
http_requests = None
|
||||||
|
|
||||||
|
_logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
WEBHOOK_TIMEOUT = 10 # seconds
|
||||||
|
|
||||||
|
|
||||||
class MaintenanceEquipment(models.Model):
|
class MaintenanceEquipment(models.Model):
|
||||||
_inherit = "maintenance.equipment"
|
_inherit = "maintenance.equipment"
|
||||||
|
|
||||||
maintenance_mode = fields.Boolean(
|
maintenance_mode = fields.Boolean(
|
||||||
string="Maintenance Mode",
|
|
||||||
default=False,
|
default=False,
|
||||||
tracking=True,
|
tracking=True,
|
||||||
)
|
)
|
||||||
maintenance_mode_start = fields.Datetime(
|
maintenance_mode_start = fields.Datetime(
|
||||||
string="Maintenance Mode Start",
|
|
||||||
readonly=True,
|
readonly=True,
|
||||||
)
|
)
|
||||||
maintenance_mode_end = fields.Datetime(
|
maintenance_mode_end = fields.Datetime(
|
||||||
string="Maintenance Mode End",
|
|
||||||
readonly=True,
|
readonly=True,
|
||||||
help="Computed from start + configured duration",
|
help="Computed from start + configured duration",
|
||||||
)
|
)
|
||||||
http_maintenance_request = fields.Many2one(
|
|
||||||
"maintenance.request",
|
|
||||||
string="HTTP Maintenance Request",
|
|
||||||
readonly=True,
|
|
||||||
)
|
|
||||||
|
|
||||||
def action_activate_maintenance_mode(self):
|
def action_activate_maintenance_mode(self):
|
||||||
for rec in self:
|
for rec in self:
|
||||||
@@ -65,31 +67,30 @@ class MaintenanceEquipment(models.Model):
|
|||||||
)
|
)
|
||||||
expired.action_deactivate_maintenance_mode()
|
expired.action_deactivate_maintenance_mode()
|
||||||
|
|
||||||
def create_http_maintenance_request(self, ko_services):
|
def create_http_maintenance_request(self, ko_service):
|
||||||
|
"""
|
||||||
|
Create or return the open maintenance.request for a single KO service.
|
||||||
|
|
||||||
|
Deduplication: if ko_service already has an open (non-done) request,
|
||||||
|
return it without creating a new one.
|
||||||
|
"""
|
||||||
self.ensure_one()
|
self.ensure_one()
|
||||||
today = fields.Date.context_today(self)
|
existing = ko_service.http_maintenance_request
|
||||||
name = f"[HTTP KO] {self.name}"
|
if existing and not existing.stage_id.done:
|
||||||
domain = [
|
|
||||||
("name", "=", name),
|
|
||||||
("equipment_id", "=", self.id),
|
|
||||||
("maintenance_type", "=", "corrective"),
|
|
||||||
("create_date", ">=", f"{today} 00:00:00"),
|
|
||||||
("create_date", "<=", f"{today} 23:59:59"),
|
|
||||||
]
|
|
||||||
existing = self.env["maintenance.request"].search(domain, limit=1)
|
|
||||||
# Check if a task with same name already exist for the day, if it’s the case : skip
|
|
||||||
if existing:
|
|
||||||
self.http_maintenance_request = existing.id
|
|
||||||
return existing
|
return existing
|
||||||
request = self.http_maintenance_request
|
status_code = ko_service.last_http_status_code
|
||||||
if request and not request.stage_id.done:
|
if status_code == -1:
|
||||||
return request
|
error_detail = "Erreur réseau (timeout / DNS / SSL)"
|
||||||
|
else:
|
||||||
|
error_detail = f"HTTP {status_code}"
|
||||||
|
name = f"[HTTP KO] {ko_service.service_url}"
|
||||||
|
description = f"Service KO: {ko_service.service_url}\n{error_detail}"
|
||||||
vals = {
|
vals = {
|
||||||
"name": name,
|
"name": name,
|
||||||
"equipment_id": self.id,
|
"equipment_id": self.id,
|
||||||
"priority": "2",
|
"priority": "2",
|
||||||
"maintenance_type": "corrective",
|
"maintenance_type": "corrective",
|
||||||
"description": self._build_ko_services_description(ko_services),
|
"description": description,
|
||||||
}
|
}
|
||||||
if self.employee_id:
|
if self.employee_id:
|
||||||
vals["employee_id"] = self.employee_id.id
|
vals["employee_id"] = self.employee_id.id
|
||||||
@@ -102,9 +103,50 @@ class MaintenanceEquipment(models.Model):
|
|||||||
if team:
|
if team:
|
||||||
vals["maintenance_team_id"] = team.id
|
vals["maintenance_team_id"] = team.id
|
||||||
request = self.env["maintenance.request"].create(vals)
|
request = self.env["maintenance.request"].create(vals)
|
||||||
self.http_maintenance_request = request.id
|
ko_service.http_maintenance_request = request.id
|
||||||
|
self._notify_webhook(request, ko_service)
|
||||||
return request
|
return request
|
||||||
|
|
||||||
def _build_ko_services_description(self, ko_services):
|
def _notify_webhook(self, request, ko_service):
|
||||||
lines = [f"Service KO: {s.service_url or s.name}" for s in ko_services]
|
"""
|
||||||
return "\n".join(lines)
|
Send a webhook notification when a new maintenance request is created.
|
||||||
|
"""
|
||||||
|
ICP = self.env["ir.config_parameter"].sudo()
|
||||||
|
webhook_url = ICP.get_param(
|
||||||
|
"maintenance_service_http_monitoring.webhook_url", ""
|
||||||
|
)
|
||||||
|
if not webhook_url:
|
||||||
|
return
|
||||||
|
webhook_user = ICP.get_param(
|
||||||
|
"maintenance_service_http_monitoring.webhook_user", ""
|
||||||
|
)
|
||||||
|
webhook_password = ICP.get_param(
|
||||||
|
"maintenance_service_http_monitoring.webhook_password", ""
|
||||||
|
)
|
||||||
|
base_url = ICP.get_param("web.base.url", "")
|
||||||
|
link = (
|
||||||
|
f"{base_url}/web#id={request.id}&model=maintenance.request&view_type=form"
|
||||||
|
)
|
||||||
|
payload = {
|
||||||
|
"id": request.id,
|
||||||
|
"name": request.name,
|
||||||
|
"description": request.description or "",
|
||||||
|
"equipment": self.name,
|
||||||
|
"link": link,
|
||||||
|
}
|
||||||
|
auth = None
|
||||||
|
if webhook_user and webhook_password:
|
||||||
|
auth = (webhook_user, webhook_password)
|
||||||
|
try:
|
||||||
|
http_requests.post(
|
||||||
|
webhook_url,
|
||||||
|
json=payload,
|
||||||
|
auth=auth,
|
||||||
|
timeout=WEBHOOK_TIMEOUT,
|
||||||
|
)
|
||||||
|
except Exception as e:
|
||||||
|
_logger.warning(
|
||||||
|
"Webhook notification failed for maintenance request %s: %s",
|
||||||
|
request.id,
|
||||||
|
e,
|
||||||
|
)
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import logging
|
import logging
|
||||||
|
from datetime import timedelta
|
||||||
|
|
||||||
from odoo import api, fields, models
|
from odoo import api, fields, models
|
||||||
|
|
||||||
@@ -9,7 +10,8 @@ except ImportError:
|
|||||||
|
|
||||||
_logger = logging.getLogger(__name__)
|
_logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
HTTP_CHECK_TIMEOUT = 10 # seconds
|
HTTP_CHECK_TIMEOUT = 20 # seconds
|
||||||
|
HTTP_KO_CONFIRMATION_DELAY = timedelta(minutes=5)
|
||||||
|
|
||||||
|
|
||||||
class ServiceInstance(models.Model):
|
class ServiceInstance(models.Model):
|
||||||
@@ -29,48 +31,122 @@ class ServiceInstance(models.Model):
|
|||||||
readonly=True,
|
readonly=True,
|
||||||
default=True,
|
default=True,
|
||||||
)
|
)
|
||||||
|
http_maintenance_request = fields.Many2one(
|
||||||
|
"maintenance.request",
|
||||||
|
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):
|
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. Does NOT create maintenance.request — the cron only opens one
|
||||||
|
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.
|
||||||
|
"""
|
||||||
|
ko_records = self.browse()
|
||||||
for rec in self:
|
for rec in self:
|
||||||
if not rec.service_url or not rec.equipment_id:
|
if not rec.service_url or not rec.equipment_id:
|
||||||
continue
|
continue
|
||||||
equipment = rec.equipment_id
|
if rec.equipment_id.maintenance_mode:
|
||||||
if getattr(equipment, "maintenance_mode", False):
|
|
||||||
continue
|
continue
|
||||||
status_ok = False
|
status_ok = False
|
||||||
status_code = -1
|
status_code = -1
|
||||||
now = fields.Datetime.now()
|
now = fields.Datetime.now()
|
||||||
url = rec.service_url
|
url = rec.service_url
|
||||||
if not url.lower().startswith("https://"):
|
if not url.lower().startswith("https://"):
|
||||||
url = "https://" + url.lstrip("http://")
|
url = "https://" + url.removeprefix("http://").removeprefix("HTTP://")
|
||||||
try:
|
try:
|
||||||
response = requests.get(url, timeout=HTTP_CHECK_TIMEOUT)
|
response = requests.get(url, timeout=HTTP_CHECK_TIMEOUT)
|
||||||
status_code = response.status_code
|
status_code = response.status_code
|
||||||
status_ok = status_code == 200
|
status_ok = status_code == 200
|
||||||
except requests.exceptions.RequestException as e:
|
except requests.exceptions.RequestException as e:
|
||||||
_logger.warning("HTTP check failed for %s: %s", rec.service_url, e)
|
_logger.warning("HTTP check failed for %s: %s", rec.service_url, e)
|
||||||
rec.write(
|
vals = {
|
||||||
{
|
|
||||||
"last_http_status_code": status_code,
|
"last_http_status_code": status_code,
|
||||||
"last_http_check_date": now,
|
"last_http_check_date": now,
|
||||||
"http_status_ok": status_ok,
|
"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)
|
||||||
if not status_ok:
|
if not status_ok:
|
||||||
# Delegate maintenance.request creation to equipment
|
ko_records |= rec
|
||||||
if hasattr(equipment, "create_http_maintenance_request"):
|
return ko_records
|
||||||
equipment.create_http_maintenance_request([rec])
|
|
||||||
|
def _close_http_maintenance_request(self):
|
||||||
|
"""
|
||||||
|
Close the open maintenance.request for each recovered service.
|
||||||
|
|
||||||
|
Moves the request to the first done stage, posts a chatter note as OdooBot, and
|
||||||
|
clears http_maintenance_request on the service instance.
|
||||||
|
"""
|
||||||
|
done_stage = self.env["maintenance.stage"].search(
|
||||||
|
[("done", "=", True)], limit=1
|
||||||
|
)
|
||||||
|
if not done_stage:
|
||||||
|
return
|
||||||
|
odoobot = self.env.ref("base.partner_root")
|
||||||
|
for rec in self:
|
||||||
|
request = rec.http_maintenance_request
|
||||||
|
if not request or request.stage_id.done:
|
||||||
|
continue
|
||||||
|
request.sudo().write({"stage_id": done_stage.id})
|
||||||
|
request.sudo().message_post(
|
||||||
|
body=(
|
||||||
|
f"Service {rec.service_url} is back online. "
|
||||||
|
"This request has been automatically closed by the monitoring cron."
|
||||||
|
),
|
||||||
|
author_id=odoobot.id,
|
||||||
|
message_type="comment",
|
||||||
|
subtype_xmlid="mail.mt_note",
|
||||||
|
)
|
||||||
|
rec.http_maintenance_request = False
|
||||||
|
|
||||||
@api.model
|
@api.model
|
||||||
def cron_check_http_services(self):
|
def cron_check_http_services(self):
|
||||||
|
"""
|
||||||
|
Check all active services with a URL.
|
||||||
|
|
||||||
|
A service must be continuously KO for at least HTTP_KO_CONFIRMATION_DELAY
|
||||||
|
before a maintenance.request is created — this tolerates transient outages
|
||||||
|
(e.g. a temporary server overload) regardless of how often this cron runs.
|
||||||
|
Services that had an open request and are now OK are auto-resolved.
|
||||||
|
"""
|
||||||
domain = [
|
domain = [
|
||||||
("active", "=", True),
|
("active", "=", True),
|
||||||
("service_url", "!=", False),
|
("service_url", "!=", False),
|
||||||
("equipment_id", "!=", False),
|
("equipment_id", "!=", False),
|
||||||
]
|
]
|
||||||
services = self.search(domain)
|
services = self.search(domain).filtered(
|
||||||
for service in services:
|
lambda s: not s.equipment_id.maintenance_mode
|
||||||
equipment = service.equipment_id
|
)
|
||||||
if getattr(equipment, "maintenance_mode", False):
|
|
||||||
continue
|
# Snapshot services that currently have an open request before the check
|
||||||
service.check_http_status()
|
services_with_open_request = services.filtered(
|
||||||
|
lambda s: s.http_maintenance_request
|
||||||
|
and not s.http_maintenance_request.stage_id.done
|
||||||
|
)
|
||||||
|
|
||||||
|
ko_services = services.check_http_status()
|
||||||
|
|
||||||
|
# Auto-resolve services that recovered
|
||||||
|
recovered = services_with_open_request.filtered(lambda s: s.http_status_ok)
|
||||||
|
if recovered:
|
||||||
|
recovered._close_http_maintenance_request()
|
||||||
|
|
||||||
|
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:
|
||||||
|
service.equipment_id.create_http_maintenance_request(service)
|
||||||
|
|||||||
1
maintenance_service_http_monitoring/tests/__init__.py
Normal file
1
maintenance_service_http_monitoring/tests/__init__.py
Normal file
@@ -0,0 +1 @@
|
|||||||
|
from . import test_http_monitoring
|
||||||
@@ -0,0 +1,413 @@
|
|||||||
|
from datetime import timedelta
|
||||||
|
from unittest.mock import MagicMock, patch
|
||||||
|
|
||||||
|
from odoo import fields
|
||||||
|
from odoo.tests.common import TransactionCase
|
||||||
|
|
||||||
|
SERVICE_INSTANCE_REQUESTS = (
|
||||||
|
"odoo.addons.maintenance_service_http_monitoring.models.service_instance.requests"
|
||||||
|
)
|
||||||
|
EQUIPMENT_HTTP_REQUESTS = (
|
||||||
|
"odoo.addons.maintenance_service_http_monitoring"
|
||||||
|
".models.maintenance_equipment.http_requests"
|
||||||
|
)
|
||||||
|
|
||||||
|
# Comfortably past HTTP_KO_CONFIRMATION_DELAY (currently 10 minutes).
|
||||||
|
PAST_CONFIRMATION_DELAY = timedelta(minutes=20)
|
||||||
|
|
||||||
|
|
||||||
|
def _mock_response(status_code):
|
||||||
|
response = MagicMock()
|
||||||
|
response.status_code = status_code
|
||||||
|
return response
|
||||||
|
|
||||||
|
|
||||||
|
class TestHttpMonitoring(TransactionCase):
|
||||||
|
def setUp(self):
|
||||||
|
super().setUp()
|
||||||
|
team = self.env["maintenance.team"].search([], limit=1)
|
||||||
|
self.equipment = self.env["maintenance.equipment"].create(
|
||||||
|
{
|
||||||
|
"name": "Test Server",
|
||||||
|
"maintenance_team_id": team.id if team else False,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
self.service = self.env["service"].create({"name": "Test Service"})
|
||||||
|
self.service_instance = self.env["service.instance"].create(
|
||||||
|
{
|
||||||
|
"equipment_id": self.equipment.id,
|
||||||
|
"service_id": self.service.id,
|
||||||
|
"service_url": "https://example.com",
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
def _backdate_first_ko(self, *service_instances):
|
||||||
|
"""Simulate that the current KO streak started long 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
|
||||||
|
# ------------------------------------------------------------------
|
||||||
|
def test_http_200_sets_status_ok(self):
|
||||||
|
with patch(SERVICE_INSTANCE_REQUESTS) as mock_requests:
|
||||||
|
mock_requests.get.return_value = _mock_response(200)
|
||||||
|
mock_requests.exceptions.RequestException = Exception
|
||||||
|
self.service_instance.check_http_status()
|
||||||
|
|
||||||
|
self.assertTrue(self.service_instance.http_status_ok)
|
||||||
|
self.assertEqual(self.service_instance.last_http_status_code, 200)
|
||||||
|
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
|
||||||
|
# ------------------------------------------------------------------
|
||||||
|
def test_http_500_creates_request_after_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.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_check_http_services()
|
||||||
|
|
||||||
|
request = self.service_instance.http_maintenance_request
|
||||||
|
self.assertTrue(request)
|
||||||
|
self.assertEqual(request.name, f"[HTTP KO] {self.service_instance.service_url}")
|
||||||
|
self.assertEqual(request.priority, "2")
|
||||||
|
self.assertEqual(request.maintenance_type, "corrective")
|
||||||
|
self.assertIn("HTTP 500", request.description)
|
||||||
|
self.assertIn(self.service_instance.service_url, request.description)
|
||||||
|
|
||||||
|
# ------------------------------------------------------------------
|
||||||
|
# Test 3 -- Network error -> KO with code -1
|
||||||
|
# ------------------------------------------------------------------
|
||||||
|
def test_network_error_sets_status_ko_and_minus_one(self):
|
||||||
|
with patch(SERVICE_INSTANCE_REQUESTS) as mock_requests:
|
||||||
|
mock_requests.get.side_effect = Exception("connection refused")
|
||||||
|
mock_requests.exceptions.RequestException = Exception
|
||||||
|
self.service_instance.check_http_status()
|
||||||
|
|
||||||
|
self.assertFalse(self.service_instance.http_status_ok)
|
||||||
|
self.assertEqual(self.service_instance.last_http_status_code, -1)
|
||||||
|
|
||||||
|
# ------------------------------------------------------------------
|
||||||
|
# Test 4 -- Repeated failure after confirmation -> a single request, no duplicate
|
||||||
|
# ------------------------------------------------------------------
|
||||||
|
def test_no_duplicate_request_on_repeated_failure(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() # 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
|
||||||
|
self.env["service.instance"].cron_check_http_services() # confirmed, request created
|
||||||
|
|
||||||
|
request_1 = self.service_instance.http_maintenance_request
|
||||||
|
self.assertTrue(request_1)
|
||||||
|
|
||||||
|
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() # still KO
|
||||||
|
|
||||||
|
self.assertEqual(self.service_instance.http_maintenance_request, request_1)
|
||||||
|
self.assertEqual(
|
||||||
|
self.env["maintenance.request"].search_count(
|
||||||
|
[("equipment_id", "=", self.equipment.id)]
|
||||||
|
),
|
||||||
|
1,
|
||||||
|
)
|
||||||
|
|
||||||
|
# ------------------------------------------------------------------
|
||||||
|
# Test 5 -- Equipment in maintenance mode -> cron skips it
|
||||||
|
# ------------------------------------------------------------------
|
||||||
|
def test_maintenance_mode_skips_http_check(self):
|
||||||
|
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_check_http_services()
|
||||||
|
|
||||||
|
mock_requests.get.assert_not_called()
|
||||||
|
self.assertFalse(self.service_instance.last_http_check_date)
|
||||||
|
|
||||||
|
# ------------------------------------------------------------------
|
||||||
|
# Test 6 -- Expired maintenance mode -> cron deactivates it
|
||||||
|
# ------------------------------------------------------------------
|
||||||
|
def test_maintenance_mode_auto_expiry(self):
|
||||||
|
past = fields.Datetime.now() - timedelta(hours=1)
|
||||||
|
self.equipment.write(
|
||||||
|
{
|
||||||
|
"maintenance_mode": True,
|
||||||
|
"maintenance_mode_start": past - timedelta(hours=4),
|
||||||
|
"maintenance_mode_end": past,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
self.assertTrue(self.equipment.maintenance_mode)
|
||||||
|
|
||||||
|
self.env["maintenance.equipment"].cron_deactivate_expired_maintenance_mode()
|
||||||
|
|
||||||
|
self.assertFalse(self.equipment.maintenance_mode)
|
||||||
|
self.assertFalse(self.equipment.maintenance_mode_start)
|
||||||
|
self.assertFalse(self.equipment.maintenance_mode_end)
|
||||||
|
|
||||||
|
# ------------------------------------------------------------------
|
||||||
|
# Test 7 -- Service without URL -> ignored by cron
|
||||||
|
# ------------------------------------------------------------------
|
||||||
|
def test_service_without_url_is_ignored(self):
|
||||||
|
self.service_instance.write({"service_url": False})
|
||||||
|
|
||||||
|
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_check_http_services()
|
||||||
|
|
||||||
|
mock_requests.get.assert_not_called()
|
||||||
|
self.assertFalse(self.service_instance.last_http_check_date)
|
||||||
|
|
||||||
|
# ------------------------------------------------------------------
|
||||||
|
# Test 8 -- HTTP 404 (non-exception) -> KO with correct code
|
||||||
|
# ------------------------------------------------------------------
|
||||||
|
def test_http_non_200_non_exception(self):
|
||||||
|
with patch(SERVICE_INSTANCE_REQUESTS) as mock_requests:
|
||||||
|
mock_requests.get.return_value = _mock_response(404)
|
||||||
|
mock_requests.exceptions.RequestException = Exception
|
||||||
|
self.service_instance.check_http_status()
|
||||||
|
|
||||||
|
self.assertFalse(self.service_instance.http_status_ok)
|
||||||
|
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
|
||||||
|
# ------------------------------------------------------------------
|
||||||
|
def test_webhook_called_on_new_request(self):
|
||||||
|
self.env["ir.config_parameter"].sudo().set_param(
|
||||||
|
"maintenance_service_http_monitoring.webhook_url",
|
||||||
|
"https://webhook.example.com/hook",
|
||||||
|
)
|
||||||
|
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_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_check_http_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")
|
||||||
|
self.assertEqual(payload["equipment"], self.equipment.name)
|
||||||
|
|
||||||
|
# ------------------------------------------------------------------
|
||||||
|
# Test 10 -- Webhook skipped when no URL configured
|
||||||
|
# ------------------------------------------------------------------
|
||||||
|
def test_webhook_skipped_when_no_url(self):
|
||||||
|
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(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()
|
||||||
|
|
||||||
|
self.assertTrue(self.service_instance.http_maintenance_request)
|
||||||
|
mock_http.post.assert_not_called()
|
||||||
|
|
||||||
|
# ------------------------------------------------------------------
|
||||||
|
# Test 11 -- Service without equipment -> check_http_status skips it
|
||||||
|
# ------------------------------------------------------------------
|
||||||
|
def test_service_without_equipment_is_ignored(self):
|
||||||
|
self.service_instance.write({"equipment_id": False})
|
||||||
|
|
||||||
|
with patch(SERVICE_INSTANCE_REQUESTS) as mock_requests:
|
||||||
|
mock_requests.get.return_value = _mock_response(200)
|
||||||
|
mock_requests.exceptions.RequestException = Exception
|
||||||
|
self.service_instance.check_http_status()
|
||||||
|
|
||||||
|
mock_requests.get.assert_not_called()
|
||||||
|
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
|
||||||
|
# ------------------------------------------------------------------
|
||||||
|
def test_transient_failure_no_request_created(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(200)
|
||||||
|
mock_requests.exceptions.RequestException = Exception
|
||||||
|
self.env["service.instance"].cron_check_http_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(
|
||||||
|
[("equipment_id", "=", self.equipment.id)]
|
||||||
|
),
|
||||||
|
0,
|
||||||
|
)
|
||||||
|
|
||||||
|
# ------------------------------------------------------------------
|
||||||
|
# Test 13 -- Confirmed failure (KO continuously past the confirmation delay)
|
||||||
|
# -> request created
|
||||||
|
# ------------------------------------------------------------------
|
||||||
|
def test_confirmed_failure_creates_request(self):
|
||||||
|
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_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_check_http_services()
|
||||||
|
|
||||||
|
self.assertEqual(mock_requests.get.call_count, 1)
|
||||||
|
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"})
|
||||||
|
service_instance2 = self.env["service.instance"].create(
|
||||||
|
{
|
||||||
|
"equipment_id": self.equipment.id,
|
||||||
|
"service_id": service2.id,
|
||||||
|
"service_url": "https://other.example.com",
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
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, 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_check_http_services()
|
||||||
|
|
||||||
|
req1 = self.service_instance.http_maintenance_request
|
||||||
|
req2 = service_instance2.http_maintenance_request
|
||||||
|
|
||||||
|
self.assertTrue(req1)
|
||||||
|
self.assertTrue(req2)
|
||||||
|
self.assertNotEqual(req1, req2)
|
||||||
|
self.assertEqual(req1.name, f"[HTTP KO] {self.service_instance.service_url}")
|
||||||
|
self.assertEqual(req2.name, f"[HTTP KO] {service_instance2.service_url}")
|
||||||
|
self.assertEqual(
|
||||||
|
self.env["maintenance.request"].search_count(
|
||||||
|
[("equipment_id", "=", self.equipment.id)]
|
||||||
|
),
|
||||||
|
2,
|
||||||
|
)
|
||||||
|
|
||||||
|
# ------------------------------------------------------------------
|
||||||
|
# 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:
|
||||||
|
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)
|
||||||
|
|
||||||
|
# Second 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_check_http_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:
|
||||||
|
mock_requests.get.return_value = _mock_response(200)
|
||||||
|
mock_requests.exceptions.RequestException = Exception
|
||||||
|
self.env["service.instance"].cron_check_http_services()
|
||||||
|
|
||||||
|
# Request must be in a done stage
|
||||||
|
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 "")
|
||||||
|
)
|
||||||
|
self.assertTrue(notes)
|
||||||
|
|
||||||
|
# ------------------------------------------------------------------
|
||||||
|
# Test 16 -- No open request -> _close_http_maintenance_request is a no-op
|
||||||
|
# ------------------------------------------------------------------
|
||||||
|
def test_no_close_when_no_open_request(self):
|
||||||
|
# Service is OK from the start, no request exists
|
||||||
|
self.assertFalse(self.service_instance.http_maintenance_request)
|
||||||
|
# Calling close directly must not raise
|
||||||
|
self.service_instance._close_http_maintenance_request()
|
||||||
|
self.assertFalse(self.service_instance.http_maintenance_request)
|
||||||
@@ -9,7 +9,7 @@
|
|||||||
<div
|
<div
|
||||||
class="alert alert-warning"
|
class="alert alert-warning"
|
||||||
role="alert"
|
role="alert"
|
||||||
attrs="{'invisible': [('maintenance_mode', '=', False)]}"
|
invisible="not maintenance_mode"
|
||||||
>
|
>
|
||||||
Mode maintenance actif — Vérifications HTTP désactivées.<br />
|
Mode maintenance actif — Vérifications HTTP désactivées.<br />
|
||||||
Fin prévue : <field name="maintenance_mode_end" readonly="1" />
|
Fin prévue : <field name="maintenance_mode_end" readonly="1" />
|
||||||
@@ -20,14 +20,14 @@
|
|||||||
name="action_activate_maintenance_mode"
|
name="action_activate_maintenance_mode"
|
||||||
type="object"
|
type="object"
|
||||||
string="Activer le mode maintenance"
|
string="Activer le mode maintenance"
|
||||||
attrs="{'invisible': [('maintenance_mode', '=', True)]}"
|
invisible="maintenance_mode"
|
||||||
class="oe_highlight"
|
class="oe_highlight"
|
||||||
/>
|
/>
|
||||||
<button
|
<button
|
||||||
name="action_deactivate_maintenance_mode"
|
name="action_deactivate_maintenance_mode"
|
||||||
type="object"
|
type="object"
|
||||||
string="Désactiver le mode maintenance"
|
string="Désactiver le mode maintenance"
|
||||||
attrs="{'invisible': [('maintenance_mode', '=', False)]}"
|
invisible="not maintenance_mode"
|
||||||
/>
|
/>
|
||||||
</xpath>
|
</xpath>
|
||||||
<xpath expr="//notebook" position="inside">
|
<xpath expr="//notebook" position="inside">
|
||||||
@@ -36,18 +36,17 @@
|
|||||||
<field name="maintenance_mode" />
|
<field name="maintenance_mode" />
|
||||||
<field name="maintenance_mode_start" />
|
<field name="maintenance_mode_start" />
|
||||||
<field name="maintenance_mode_end" />
|
<field name="maintenance_mode_end" />
|
||||||
<field name="http_maintenance_request" readonly="1" />
|
|
||||||
</group>
|
</group>
|
||||||
</page>
|
</page>
|
||||||
</xpath>
|
</xpath>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
<record id="view_equipment_tree_http_monitoring" model="ir.ui.view">
|
<record id="view_equipment_tree_http_monitoring" model="ir.ui.view">
|
||||||
<field name="name">maintenance.equipment.tree.http.monitoring</field>
|
<field name="name">maintenance.equipment.list.http.monitoring</field>
|
||||||
<field name="model">maintenance.equipment</field>
|
<field name="model">maintenance.equipment</field>
|
||||||
<field name="inherit_id" ref="maintenance.hr_equipment_view_tree" />
|
<field name="inherit_id" ref="maintenance.hr_equipment_view_tree" />
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<xpath expr="//tree" position="inside">
|
<xpath expr="//list" position="inside">
|
||||||
<field name="maintenance_mode" optional="hide" />
|
<field name="maintenance_mode" optional="hide" />
|
||||||
</xpath>
|
</xpath>
|
||||||
</field>
|
</field>
|
||||||
|
|||||||
@@ -1,22 +1,24 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" ?>
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
<odoo>
|
<odoo>
|
||||||
<!-- Inherit from base tree view to add HTTP monitoring fields -->
|
<!-- Inherit from base list view to add HTTP monitoring fields -->
|
||||||
<record id="service_instance_http_monitoring_tree" model="ir.ui.view">
|
<record id="service_instance_http_monitoring_tree" model="ir.ui.view">
|
||||||
<field name="name">service.instance.http.monitoring.tree</field>
|
<field name="name">service.instance.http.monitoring.list</field>
|
||||||
<field name="model">service.instance</field>
|
<field name="model">service.instance</field>
|
||||||
<field
|
<field
|
||||||
name="inherit_id"
|
name="inherit_id"
|
||||||
ref="maintenance_server_data.service_instance_view_tree"
|
ref="maintenance_server_data.service_instance_view_tree"
|
||||||
/>
|
/>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<tree position="attributes">
|
<list position="attributes">
|
||||||
<attribute name="decoration-danger">http_status_ok == False</attribute>
|
<attribute name="decoration-danger">http_status_ok == False</attribute>
|
||||||
</tree>
|
</list>
|
||||||
<field name="version_id" position="after">
|
<field name="version_id" position="after">
|
||||||
<field name="service_url" />
|
<field name="service_url" />
|
||||||
<field name="last_http_check_date" />
|
<field name="last_http_check_date" />
|
||||||
<field name="last_http_status_code" />
|
<field name="last_http_status_code" />
|
||||||
<field name="http_status_ok" />
|
<field name="http_status_ok" />
|
||||||
|
<field name="http_maintenance_request" optional="hide" />
|
||||||
|
<field name="http_first_ko_at" optional="hide" />
|
||||||
</field>
|
</field>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|||||||
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