Skip to content

Commit

Permalink
[MIG] mgmtsystem_nonconformity: Migration to 18.0
Browse files Browse the repository at this point in the history
  • Loading branch information
natuan9 committed Dec 17, 2024
1 parent 48dd6b6 commit 26785db
Show file tree
Hide file tree
Showing 19 changed files with 158 additions and 223 deletions.
118 changes: 58 additions & 60 deletions mgmtsystem_nonconformity/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,25 +17,25 @@ Management System - Nonconformity
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fmanagement--system-lightgray.png?logo=github
:target: https://github.com/OCA/management-system/tree/17.0/mgmtsystem_nonconformity
:target: https://github.com/OCA/management-system/tree/18.0/mgmtsystem_nonconformity
:alt: OCA/management-system
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/management-system-17-0/management-system-17-0-mgmtsystem_nonconformity
:target: https://translation.odoo-community.org/projects/management-system-18-0/management-system-18-0-mgmtsystem_nonconformity
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/management-system&target_branch=17.0
:target: https://runboat.odoo-community.org/builds?repo=OCA/management-system&target_branch=18.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

This module enables you to manage the nonconformities of your management
systems:

- Quality (ISO 9001)
- Environment (ISO 14001)
- Information Security (ISO 27001)
- Health and Safety (ISO 45001)
- IT Services (ISO 20000)
- Quality (ISO 9001)
- Environment (ISO 14001)
- Information Security (ISO 27001)
- Health and Safety (ISO 45001)
- IT Services (ISO 20000)

**Table of contents**

Expand All @@ -47,54 +47,51 @@ Configuration

Users must be added to the appropriate groups within Odoo as follows:

- Creators: Settings > Users > Groups > Management System / User

To configure email notifications for certain stages go to:

- Management System > Configuration > Nonconformities > Stages
- Click on any stage and click the edit button.
- Click on the dropdown icon in the field Email Template, select your
template and click Save.
- Creators: Settings > Users > Groups > Management System / User

Usage
=====

To use this module:

- Go to Management System > Nonconformities
- Click on Create to enter the following information:
- Partner : Customer, supplier or internal personnel
- Related to: Any reference pointing to the NC (order id, project id,
task id, etc.)
- Responsible: Person responsible for the NC
- Manager : Person managing the department or owner of the procedure
- Filled in by: Originator of NC report
- Origins: The source of the NC, how was it discover
- Procedures: Against which procedure is the NC
- Description: Evidence, reference to the standards
- Click on Save and then on Analysis.

Go to the newly created NC and fill in the following information in the
tab named Causes and Analysis:

- Causes: Add root causes
- Analysis: Describe the results of the investigation
- Severity: Select the severity among unfounded, minor and major
- Immediate action: Create or select an immediate action if appropriate
- Go to Management System > Nonconformities
- Click on Create to enter the following information:
- Partner : Customer, supplier or internal personnel
- Related to: Any reference pointing to the NC (order id, project id,
task id, etc.)
- Responsible: Person responsible for the NC
- Manager : Person managing the department or owner of the procedure
- Filled in by: Originator of NC report
- Origins: The source of the NC, how was it discover
- Procedures: Against which procedure is the NC
- Description: Evidence, reference to the standards
- Click on Save and then set state from Draft to Analysis.

Go to the newly created NC and fill in the following information:

In the Causes and Analysis tab:

- Causes: Add root causes
- Analysis: Describe the results of the investigation
- Severity: Select the severity among unfounded, minor and major

In the Description tab:

- Immediate action: Create or select an immediate action if appropriate

Click on the Save button and then on the "Action Plan" button in the top
right corner.

In the Actions tab, select or create new actions by entering the
following items:

- Subject: What must be done - Return to Supplier, Use As Is, Scrap,
Rework, Re-grade, Repair
- Deadline: Date by which the action must be completed
- Responsible: Person in charge for implementing the action
- Type: Immediate, corrective or preventive actions or improvement
opportunity
- Description: Details of the action
- Subject: What must be done - Return to Supplier, Use As Is, Scrap,
Rework, Re-grade, Repair
- Deadline: Date by which the action must be completed
- Responsible: Person in charge for implementing the action
- Response Type: Immediate, corrective or preventive actions or
improvement opportunity
- Description: Details of the action

When the action is created, a notification is sent to the person
responsible for the action.
Expand All @@ -111,18 +108,18 @@ evaluated before closing the NC.
Known issues / Roadmap
======================

- The custom emails should be replaced by Mail Tracking features and
Subtypes (like in Project Tasks and Project Issues)
- Automatically add responsible_user_id._uid, manager_user_id._uid,
author_user_id._uid to chatter
- The custom emails should be replaced by Mail Tracking features and
Subtypes (like in Project Tasks and Project Issues)
- Automatically add responsible_user_id._uid, manager_user_id._uid,
author_user_id._uid to chatter

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/management-system/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/management-system/issues/new?body=module:%20mgmtsystem_nonconformity%0Aversion:%2017.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
`feedback <https://github.com/OCA/management-system/issues/new?body=module:%20mgmtsystem_nonconformity%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Expand All @@ -137,27 +134,28 @@ Authors
Contributors
------------

- Daniel Reis <[email protected]>
- Glen Dromgoole <[email protected]>
- Loic Lacroix <[email protected]>
- Sandy Carter <[email protected]>
- Gervais Naoussi <[email protected]>
- Eugen Don <[email protected]>
- Jose Maria Alzaga <[email protected]>
- `Tecnativa <https://www.tecnativa.com>`__:
- Daniel Reis <[email protected]>
- Glen Dromgoole <[email protected]>
- Loic Lacroix <[email protected]>
- Sandy Carter <[email protected]>
- Gervais Naoussi <[email protected]>
- Eugen Don <[email protected]>
- Jose Maria Alzaga <[email protected]>
- `Tecnativa <https://www.tecnativa.com>`__:

- Ernesto Tejeda
- Ernesto Tejeda

Trobz

- Dung Tran <[email protected]>
- Dung Tran <[email protected]>
- Tuan Nguyen <[email protected]>

Other credits
-------------

The development of this module has been financially supported by:

- Camptocamp
- Camptocamp

Maintainers
-----------
Expand All @@ -172,6 +170,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.

This module is part of the `OCA/management-system <https://github.com/OCA/management-system/tree/17.0/mgmtsystem_nonconformity>`_ project on GitHub.
This module is part of the `OCA/management-system <https://github.com/OCA/management-system/tree/18.0/mgmtsystem_nonconformity>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
2 changes: 1 addition & 1 deletion mgmtsystem_nonconformity/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{
"name": "Management System - Nonconformity",
"version": "17.0.1.0.0",
"version": "18.0.1.0.0",
"author": "Savoir-faire Linux, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/management-system",
"license": "AGPL-3",
Expand Down
2 changes: 1 addition & 1 deletion mgmtsystem_nonconformity/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@
from . import mgmtsystem_nonconformity_severity
from . import mgmtsystem_nonconformity
from . import mgmtsystem_action
from . import mgmtsystem_nonconformity_abstract
from . import mail_thread
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@
from odoo.tools.misc import frozendict


class MgmtsystemNonconformityAbstract(models.AbstractModel):
# TODO: Remove this on 17.0 and move everything on mail.thread
_name = "mgmtsystem.nonconformity.abstract"
_description = "Nonconformity Abstract"
class MailThread(models.AbstractModel):
_inherit = "mail.thread"

non_conformity_ids = fields.One2many(
"mgmtsystem.nonconformity",
Expand Down Expand Up @@ -41,11 +39,6 @@ def action_view_non_conformities(self):
action["context"] = self._get_non_conformities_context()
return action


class MailThread(models.AbstractModel):
_name = "mail.thread"
_inherit = ["mail.thread", "mgmtsystem.nonconformity.abstract"]

@api.model
def get_view(self, view_id=None, view_type="form", **options):
res = super().get_view(view_id=view_id, view_type=view_type, **options)
Expand All @@ -59,7 +52,7 @@ def get_view(self, view_id=None, view_type="form", **options):

# We need to copy, because it is a frozen dict
all_models = res["models"].copy()
for node in doc.xpath("/form/div[hasclass('oe_chatter')]"):
for node in doc.xpath("/form/chatter"):
# _add_tier_validation_label process
new_node = etree.fromstring(
"<field name='non_conformity_count' invisible='1'/>"
Expand All @@ -83,6 +76,7 @@ def _get_view_fields(self, view_type, models):
trees inside a form
"""
result = super()._get_view_fields(view_type, models)

if view_type == "form" and self.env.user.has_group(
"mgmtsystem.group_mgmtsystem_viewer"
):
Expand Down
3 changes: 1 addition & 2 deletions mgmtsystem_nonconformity/models/mgmtsystem_action.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,12 @@ class MgmtsystemAction(models.Model):
_inherit = "mgmtsystem.action"

nonconformity_immediate_id = fields.One2many(
"mgmtsystem.nonconformity", "immediate_action_id", readonly=True
"mgmtsystem.nonconformity", "immediate_action_id"
)
nonconformity_ids = fields.Many2many(
"mgmtsystem.nonconformity",
"mgmtsystem_nonconformity_action_rel",
"action_id",
"nonconformity_id",
"Nonconformities",
readonly=True,
)
24 changes: 12 additions & 12 deletions mgmtsystem_nonconformity/models/mgmtsystem_nonconformity.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).


from odoo import _, api, fields, models
from odoo import api, fields, models


class MgmtsystemNonconformity(models.Model):
Expand All @@ -19,27 +19,24 @@ def _default_stage(self):
].search([("is_starting", "=", True)], limit=1)

@api.model
def _stage_groups(self, stages, domain, order):
def _stage_groups(self, stages, domain):
stage_ids = self.env["mgmtsystem.nonconformity.stage"].search([])
return stage_ids

# 1. Description
name = fields.Char()
ref = fields.Char("Reference", required=True, readonly=True, default="NEW")
ref = fields.Char("Reference", required=True, default="NEW")
# Compute data
number_of_nonconformities = fields.Integer(
"# of nonconformities", readonly=True, default=1
)
number_of_nonconformities = fields.Integer("# of nonconformities", default=1)
days_since_updated = fields.Integer(
readonly=True, compute="_compute_days_since_updated", store=True
compute="_compute_days_since_updated", store=True
)
number_of_days_to_close = fields.Integer(
"# of days to close",
compute="_compute_number_of_days_to_close",
store=True,
readonly=True,
)
closing_date = fields.Datetime(readonly=True)
closing_date = fields.Datetime()

partner_id = fields.Many2one("res.partner", "Partner", required=True)
reference = fields.Char(
Expand Down Expand Up @@ -163,7 +160,7 @@ def _check_open_with_action_comments(self):
for nc in self:
if nc.state == "open" and not nc.action_comments:
raise models.ValidationError(
_(
self.env._(
"Action plan comments are required "
"in order to put a nonconformity In Progress."
)
Expand All @@ -175,15 +172,18 @@ def _check_close_with_evaluation(self):
if nc.state == "done":
if not nc.evaluation_comments:
raise models.ValidationError(
_(
self.env._(
"Evaluation Comments are required "
"in order to close a Nonconformity."
)
)
actions_are_closed = nc._get_all_actions().mapped("stage_id.is_ending")
if not all(actions_are_closed):
raise models.ValidationError(
_("All actions must be done " "before closing a Nonconformity.")
self.env._(
"All actions must be done "
"before closing a Nonconformity."
)
)

@api.model
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class MgmtsystemNonconformityCause(models.Model):
name = fields.Char("Cause", required=True, translate=True)
description = fields.Text()
sequence = fields.Integer(help="Defines the order to present items")
parent_path = fields.Char(index=True, unaccent=False)
parent_path = fields.Char(index=True)
parent_id = fields.Many2one(
"mgmtsystem.nonconformity.cause", "Group", ondelete="restrict"
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class MgmtsystemNonconformityOrigin(models.Model):
name = fields.Char("Origin", required=True, translate=True)
description = fields.Text()
sequence = fields.Integer(help="Defines the order to present items")
parent_path = fields.Char(index=True, unaccent=False)
parent_path = fields.Char(index=True)
parent_id = fields.Many2one(
"mgmtsystem.nonconformity.origin", "Group", ondelete="restrict"
)
Expand Down
23 changes: 12 additions & 11 deletions mgmtsystem_nonconformity/models/mgmtsystem_nonconformity_stage.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,7 @@
# Copyright (C) 2010 Savoir-faire Linux (<http://www.savoirfairelinux.com>).
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import _, fields, models

_STATES = [
("draft", _("Draft")),
("analysis", _("Analysis")),
("pending", _("Action Plan")),
("open", _("In Progress")),
("done", _("Closed")),
("cancel", _("Cancelled")),
]
from odoo import fields, models


class MgmtsystemNonconformityStage(models.Model):
Expand All @@ -20,11 +11,21 @@ class MgmtsystemNonconformityStage(models.Model):
_description = "Nonconformity Stages"
_order = "sequence"

def _get_states(self):
return [
("draft", self.env._("Draft")),
("analysis", self.env._("Analysis")),
("pending", self.env._("Action Plan")),
("open", self.env._("In Progress")),
("done", self.env._("Closed")),
("cancel", self.env._("Cancelled")),
]

name = fields.Char("Stage Name", required=True, translate=True)
sequence = fields.Integer(
help="Used to order states. Lower is better.", default=100
)
state = fields.Selection(_STATES, default="draft")
state = fields.Selection(selection=_get_states, default="draft")
is_starting = fields.Boolean(
string="Is starting Stage",
help="select stis checkbox if this is the default stage \n"
Expand Down
Loading

0 comments on commit 26785db

Please sign in to comment.