diff --git a/mgmtsystem_review_copy_lines/README.rst b/mgmtsystem_review_copy_lines/README.rst new file mode 100644 index 000000000..146e40d14 --- /dev/null +++ b/mgmtsystem_review_copy_lines/README.rst @@ -0,0 +1,106 @@ +.. image:: https://odoo-community.org/readme-banner-image + :target: https://odoo-community.org/get-involved?utm_source=readme + :alt: Odoo Community Association + +=================================== +Management System Review Copy Lines +=================================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:4a07dffe0295229f20e8d8f40e36e29f345d511529e2ee10d7f9f3326058c976 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png + :target: https://odoo-community.org/page/development-status + :alt: Beta +.. |badge2| image:: https://img.shields.io/badge/license-AGPL--3-blue.png + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-NuoBiT%2Fodoo--addons-lightgray.png?logo=github + :target: https://github.com/NuoBiT/odoo-addons/tree/14.0/mgmtsystem_review_copy_lines + :alt: NuoBiT/odoo-addons + +|badge1| |badge2| |badge3| + +This module makes duplicating a management system review also duplicate its +review lines, and makes every duplicate start as an open review. + +Out of the box, duplicating a review yields an almost empty copy: the review +lines are not carried over (One2many fields are not copied by default) and the +state of the source review is kept, so duplicating a closed review produces a +copy that is already closed and read-only. + +With this module, duplicating a review: + +* copies every review line (title, type, linked action or nonconformity and + decision) as new line records attached to the copy, +* always starts the copy in the *Open* state, regardless of the state of the + source review, +* keeps assigning a fresh reference to the copy, as before. + +This enables a template-based workflow: keep a review with the standard set of +lines (with empty decisions) and duplicate it whenever a new review with the +same structure is needed, instead of re-creating the lines one by one. + +The faithful copy of the lines is intentional: it includes the decision text +and the linked action or nonconformity of every line. When duplicating a +review that has already been filled in — instead of a template — the copied +lines carry that content over, and it must be reviewed and cleared by hand +where it does not apply to the new review. + +**Table of contents** + +.. contents:: + :local: + +Usage +===== + +#. Create a template review under *Management System > Reviews* and add the + lines you want to reuse, leaving their decisions empty. +#. Whenever a new review with the same structure is needed, open the template + review and use *Action > Duplicate*. +#. The copy starts open, gets its own reference and contains a full copy of + the lines; adjust its title and date and fill in the decisions. + +Lines are copied verbatim: if you duplicate a review that has already been +filled in instead of a template, the copy carries over the decision texts and +the linked actions or nonconformities of the source, and they must be +reviewed and cleared by hand. + +Bug Tracker +=========== + +Bugs are tracked on `GitHub 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 `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* NuoBiT Solutions +* S.L. + +Contributors +~~~~~~~~~~~~ + +* `NuoBiT `__: + + * Deniz Gallo + +Maintainers +~~~~~~~~~~~ + +This module is part of the `NuoBiT/odoo-addons `_ project on GitHub. + +You are welcome to contribute. diff --git a/mgmtsystem_review_copy_lines/__init__.py b/mgmtsystem_review_copy_lines/__init__.py new file mode 100644 index 000000000..0650744f6 --- /dev/null +++ b/mgmtsystem_review_copy_lines/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/mgmtsystem_review_copy_lines/__manifest__.py b/mgmtsystem_review_copy_lines/__manifest__.py new file mode 100644 index 000000000..ca3c6e2ec --- /dev/null +++ b/mgmtsystem_review_copy_lines/__manifest__.py @@ -0,0 +1,14 @@ +# Copyright 2026 NuoBiT Solutions SL - Deniz Gallo +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +{ + "name": "Management System Review Copy Lines", + "summary": "Duplicate management system reviews together with their " + "lines so a template review can be reused", + "version": "14.0.1.0.0", + "category": "Management System", + "author": "NuoBiT Solutions, S.L.", + "website": "https://github.com/nuobit/odoo-addons", + "license": "AGPL-3", + "depends": ["mgmtsystem_review"], +} diff --git a/mgmtsystem_review_copy_lines/models/__init__.py b/mgmtsystem_review_copy_lines/models/__init__.py new file mode 100644 index 000000000..e60ad5ac2 --- /dev/null +++ b/mgmtsystem_review_copy_lines/models/__init__.py @@ -0,0 +1 @@ +from . import mgmtsystem_review diff --git a/mgmtsystem_review_copy_lines/models/mgmtsystem_review.py b/mgmtsystem_review_copy_lines/models/mgmtsystem_review.py new file mode 100644 index 000000000..06591e3d7 --- /dev/null +++ b/mgmtsystem_review_copy_lines/models/mgmtsystem_review.py @@ -0,0 +1,11 @@ +# Copyright 2026 NuoBiT Solutions SL - Deniz Gallo +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import fields, models + + +class MgmtsystemReview(models.Model): + _inherit = "mgmtsystem.review" + + line_ids = fields.One2many(copy=True) + state = fields.Selection(copy=False) diff --git a/mgmtsystem_review_copy_lines/readme/CONTRIBUTORS.rst b/mgmtsystem_review_copy_lines/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000..625d3c6c8 --- /dev/null +++ b/mgmtsystem_review_copy_lines/readme/CONTRIBUTORS.rst @@ -0,0 +1,3 @@ +* `NuoBiT `__: + + * Deniz Gallo diff --git a/mgmtsystem_review_copy_lines/readme/DESCRIPTION.rst b/mgmtsystem_review_copy_lines/readme/DESCRIPTION.rst new file mode 100644 index 000000000..940eca041 --- /dev/null +++ b/mgmtsystem_review_copy_lines/readme/DESCRIPTION.rst @@ -0,0 +1,25 @@ +This module makes duplicating a management system review also duplicate its +review lines, and makes every duplicate start as an open review. + +Out of the box, duplicating a review yields an almost empty copy: the review +lines are not carried over (One2many fields are not copied by default) and the +state of the source review is kept, so duplicating a closed review produces a +copy that is already closed and read-only. + +With this module, duplicating a review: + +* copies every review line (title, type, linked action or nonconformity and + decision) as new line records attached to the copy, +* always starts the copy in the *Open* state, regardless of the state of the + source review, +* keeps assigning a fresh reference to the copy, as before. + +This enables a template-based workflow: keep a review with the standard set of +lines (with empty decisions) and duplicate it whenever a new review with the +same structure is needed, instead of re-creating the lines one by one. + +The faithful copy of the lines is intentional: it includes the decision text +and the linked action or nonconformity of every line. When duplicating a +review that has already been filled in — instead of a template — the copied +lines carry that content over, and it must be reviewed and cleared by hand +where it does not apply to the new review. diff --git a/mgmtsystem_review_copy_lines/readme/USAGE.rst b/mgmtsystem_review_copy_lines/readme/USAGE.rst new file mode 100644 index 000000000..8539f554f --- /dev/null +++ b/mgmtsystem_review_copy_lines/readme/USAGE.rst @@ -0,0 +1,11 @@ +#. Create a template review under *Management System > Reviews* and add the + lines you want to reuse, leaving their decisions empty. +#. Whenever a new review with the same structure is needed, open the template + review and use *Action > Duplicate*. +#. The copy starts open, gets its own reference and contains a full copy of + the lines; adjust its title and date and fill in the decisions. + +Lines are copied verbatim: if you duplicate a review that has already been +filled in instead of a template, the copy carries over the decision texts and +the linked actions or nonconformities of the source, and they must be +reviewed and cleared by hand. diff --git a/mgmtsystem_review_copy_lines/static/description/icon.png b/mgmtsystem_review_copy_lines/static/description/icon.png new file mode 100644 index 000000000..1cd641e79 Binary files /dev/null and b/mgmtsystem_review_copy_lines/static/description/icon.png differ diff --git a/mgmtsystem_review_copy_lines/static/description/index.html b/mgmtsystem_review_copy_lines/static/description/index.html new file mode 100644 index 000000000..217a58d76 --- /dev/null +++ b/mgmtsystem_review_copy_lines/static/description/index.html @@ -0,0 +1,463 @@ + + + + + +README.rst + + + +
+ + + +Odoo Community Association + +
+

Management System Review Copy Lines

+ +

Beta License: AGPL-3 NuoBiT/odoo-addons

+

This module makes duplicating a management system review also duplicate its +review lines, and makes every duplicate start as an open review.

+

Out of the box, duplicating a review yields an almost empty copy: the review +lines are not carried over (One2many fields are not copied by default) and the +state of the source review is kept, so duplicating a closed review produces a +copy that is already closed and read-only.

+

With this module, duplicating a review:

+
    +
  • copies every review line (title, type, linked action or nonconformity and +decision) as new line records attached to the copy,
  • +
  • always starts the copy in the Open state, regardless of the state of the +source review,
  • +
  • keeps assigning a fresh reference to the copy, as before.
  • +
+

This enables a template-based workflow: keep a review with the standard set of +lines (with empty decisions) and duplicate it whenever a new review with the +same structure is needed, instead of re-creating the lines one by one.

+

The faithful copy of the lines is intentional: it includes the decision text +and the linked action or nonconformity of every line. When duplicating a +review that has already been filled in — instead of a template — the copied +lines carry that content over, and it must be reviewed and cleared by hand +where it does not apply to the new review.

+

Table of contents

+ +
+

Usage

+
    +
  1. Create a template review under Management System > Reviews and add the +lines you want to reuse, leaving their decisions empty.
  2. +
  3. Whenever a new review with the same structure is needed, open the template +review and use Action > Duplicate.
  4. +
  5. The copy starts open, gets its own reference and contains a full copy of +the lines; adjust its title and date and fill in the decisions.
  6. +
+

Lines are copied verbatim: if you duplicate a review that has already been +filled in instead of a template, the copy carries over the decision texts and +the linked actions or nonconformities of the source, and they must be +reviewed and cleared by hand.

+
+
+

Bug Tracker

+

Bugs are tracked on GitHub 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.

+

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

+
+
+

Credits

+
+

Authors

+
    +
  • NuoBiT Solutions
  • +
  • S.L.
  • +
+
+
+

Contributors

+ +
+
+

Maintainers

+

This module is part of the NuoBiT/odoo-addons project on GitHub.

+

You are welcome to contribute.

+
+
+
+
+ + diff --git a/mgmtsystem_review_copy_lines/tests/__init__.py b/mgmtsystem_review_copy_lines/tests/__init__.py new file mode 100644 index 000000000..548ed134b --- /dev/null +++ b/mgmtsystem_review_copy_lines/tests/__init__.py @@ -0,0 +1 @@ +from . import test_review_copy_lines diff --git a/mgmtsystem_review_copy_lines/tests/test_review_copy_lines.py b/mgmtsystem_review_copy_lines/tests/test_review_copy_lines.py new file mode 100644 index 000000000..37abba15a --- /dev/null +++ b/mgmtsystem_review_copy_lines/tests/test_review_copy_lines.py @@ -0,0 +1,64 @@ +# Copyright 2026 NuoBiT Solutions SL - Deniz Gallo +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo.tests.common import TransactionCase + + +class TestReviewCopyLines(TransactionCase): + def setUp(self): + super().setUp() + self.review = self.env["mgmtsystem.review"].create( + { + "name": "Template review", + "date": "2026-06-12 10:00:00", + "line_ids": [ + (0, 0, {"name": "Change description"}), + (0, 0, {"name": "Change reason", "decision": "Pending"}), + (0, 0, {"name": "Linked action", "type": "action"}), + ], + } + ) + + def test_copy_includes_lines(self): + copy = self.review.copy() + self.assertEqual(len(copy.line_ids), 3) + for field in ("name", "type", "decision"): + self.assertEqual( + copy.line_ids.mapped(field), + self.review.line_ids.mapped(field), + ) + self.assertFalse( + set(copy.line_ids.ids) & set(self.review.line_ids.ids), + "Copied lines must be new records, not shared with the source.", + ) + self.assertEqual( + len(self.review.line_ids), + 3, + "The source review must keep its own lines.", + ) + + def test_copy_starts_open(self): + self.review.button_close() + self.assertEqual(self.review.state, "done") + copy = self.review.copy() + self.assertEqual( + copy.state, + "open", + "A duplicate must start open even if the source is closed.", + ) + self.assertEqual( + self.review.state, + "done", + "Duplicating must not alter the source review.", + ) + copy.button_close() + self.assertEqual( + copy.state, + "done", + "The copy must be able to go through its own lifecycle.", + ) + + def test_copy_gets_new_reference(self): + copy = self.review.copy() + self.assertTrue(copy.reference) + self.assertNotEqual(copy.reference, self.review.reference) diff --git a/setup/mgmtsystem_review_copy_lines/odoo/addons/mgmtsystem_review_copy_lines b/setup/mgmtsystem_review_copy_lines/odoo/addons/mgmtsystem_review_copy_lines new file mode 120000 index 000000000..677dcdfc0 --- /dev/null +++ b/setup/mgmtsystem_review_copy_lines/odoo/addons/mgmtsystem_review_copy_lines @@ -0,0 +1 @@ +../../../../mgmtsystem_review_copy_lines \ No newline at end of file diff --git a/setup/mgmtsystem_review_copy_lines/setup.py b/setup/mgmtsystem_review_copy_lines/setup.py new file mode 100644 index 000000000..28c57bb64 --- /dev/null +++ b/setup/mgmtsystem_review_copy_lines/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)