mirror of
https://github.com/bringout/oca-technical.git
synced 2026-04-22 18:12:10 +02:00
Initial commit: OCA Technical packages (595 packages)
This commit is contained in:
commit
2cc02aac6e
24950 changed files with 2318079 additions and 0 deletions
|
|
@ -0,0 +1 @@
|
|||
from . import mgmtsystem_action_report
|
||||
|
|
@ -0,0 +1,92 @@
|
|||
from odoo import fields, models, tools
|
||||
|
||||
|
||||
class MgmtsystemtActionReport(models.Model):
|
||||
"""Management System Action Report."""
|
||||
|
||||
_name = "mgmtsystem.action.report"
|
||||
_auto = False
|
||||
_description = "Management System Action Report"
|
||||
_rec_name = "id"
|
||||
|
||||
# Compute data
|
||||
number_of_actions = fields.Integer("# of actions", readonly=True)
|
||||
age = fields.Integer(readonly=True)
|
||||
number_of_days_to_open = fields.Integer("# of days to open", readonly=True)
|
||||
number_of_days_to_close = fields.Integer("# of days to close", readonly=True)
|
||||
number_of_exceedings_days = fields.Integer("# of exceedings days", readonly=True)
|
||||
|
||||
# Grouping view
|
||||
type_action = fields.Selection(
|
||||
[
|
||||
("immediate", "Immediate Action"),
|
||||
("correction", "Corrective Action"),
|
||||
("prevention", "Preventive Action"),
|
||||
("improvement", "Improvement Opportunity"),
|
||||
],
|
||||
"Response Type",
|
||||
)
|
||||
create_date = fields.Datetime(readonly=True, index=True)
|
||||
date_open = fields.Datetime("Opening Date", readonly=True, index=True)
|
||||
date_closed = fields.Datetime("Close Date", readonly=True, index=True)
|
||||
date_deadline = fields.Date("Deadline", readonly=True, index=True)
|
||||
user_id = fields.Many2one("res.users", "User", readonly=True)
|
||||
stage_id = fields.Many2one("mgmtsystem.action.stage", "Stage", readonly=True)
|
||||
system_id = fields.Many2one("mgmtsystem.system", "System", readonly=True)
|
||||
|
||||
def _query(
|
||||
self, with_clause="", fields="", where_clause="", groupby="", from_clause=""
|
||||
):
|
||||
with_ = ("WITH %s" % with_clause) if with_clause else ""
|
||||
|
||||
select_ = (
|
||||
"""
|
||||
m.id,
|
||||
m.date_closed as date_closed,
|
||||
m.date_deadline as date_deadline,
|
||||
m.date_open as date_open,
|
||||
m.user_id,
|
||||
m.stage_id,
|
||||
m.system_id,
|
||||
m.type_action as type_action,
|
||||
m.create_date as create_date,
|
||||
m.number_of_days_to_open as number_of_days_to_open,
|
||||
m.number_of_days_to_close as number_of_days_to_close,
|
||||
avg(extract('epoch' from (current_date-m.create_date))
|
||||
)/(3600*24) as age,
|
||||
avg(extract('epoch' from (m.date_closed - m.date_deadline))
|
||||
)/(3600*24) as number_of_exceedings_days,
|
||||
count(*) AS number_of_actions %s
|
||||
"""
|
||||
% fields
|
||||
)
|
||||
|
||||
from_ = (
|
||||
"""
|
||||
mgmtsystem_action m
|
||||
%s
|
||||
"""
|
||||
% from_clause
|
||||
)
|
||||
|
||||
where_ = ("WHERE %s" % where_clause) if where_clause else ""
|
||||
|
||||
groupby_ = """
|
||||
m.user_id,m.system_id, m.stage_id, m.date_open,
|
||||
m.create_date,m.type_action,m.date_deadline,
|
||||
m.date_closed, m.id, m.number_of_days_to_open,
|
||||
m.number_of_days_to_close %s
|
||||
""" % (
|
||||
groupby
|
||||
)
|
||||
|
||||
return "{} (SELECT {} FROM {} {} GROUP BY {})".format(
|
||||
with_, select_, from_, where_, groupby_
|
||||
)
|
||||
|
||||
def init(self):
|
||||
"""Display a pivot view of action."""
|
||||
tools.drop_view_if_exists(self._cr, "mgmtsystem_action_report")
|
||||
self.env.cr.execute( # pylint: disable=E8103
|
||||
"CREATE or REPLACE VIEW {} as ({})".format(self._table, self._query())
|
||||
)
|
||||
|
|
@ -0,0 +1,43 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<odoo>
|
||||
|
||||
<!-- Management System Action Report Pivot View -->
|
||||
|
||||
<record id="view_report_mgmtsystem_action_pivot" model="ir.ui.view">
|
||||
<field name="name">mgmtsystem.action.report.pivot</field>
|
||||
<field name="model">mgmtsystem.action.report</field>
|
||||
<field name="arch" type="xml">
|
||||
<pivot string="Actions" disable_linking="True">
|
||||
<field name="stage_id" type="row" />
|
||||
<field name="user_id" type="col" />
|
||||
<field name="number_of_actions" type="measure" />
|
||||
</pivot>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<!-- Management System Action Report Graph View -->
|
||||
|
||||
<record id="view_report_mgmtsystem_action_graph" model="ir.ui.view">
|
||||
<field name="name">mgmtsystem.action.report.graph</field>
|
||||
<field name="model">mgmtsystem.action.report</field>
|
||||
<field name="arch" type="xml">
|
||||
<graph string="Actions">
|
||||
<field name="stage_id" />
|
||||
<field name="user_id" />
|
||||
<field name="number_of_actions" type="measure" />
|
||||
</graph>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<!-- Management system Action Report Action -->
|
||||
|
||||
<record id="action_report_mgmtsystem_action" model="ir.actions.act_window">
|
||||
<field name="name">Management System Analysis</field>
|
||||
<field name="res_model">mgmtsystem.action.report</field>
|
||||
<field name="view_mode">pivot,graph</field>
|
||||
<field
|
||||
name="help"
|
||||
>Have a general overview of all actions processed in the system by sorting them with specific criteria.</field>
|
||||
</record>
|
||||
|
||||
</odoo>
|
||||
Loading…
Add table
Add a link
Reference in a new issue