diff --git a/purchase_requisition_sequence_option/README.rst b/purchase_requisition_sequence_option/README.rst new file mode 100644 index 00000000000..91e054caf70 --- /dev/null +++ b/purchase_requisition_sequence_option/README.rst @@ -0,0 +1,92 @@ +================================== +Purchase Agreement Sequence Option +================================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:d997e8406f9df080383be8f60c3f7cd02ab485bffc2e4978c5e28804c7d01047 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Alpha-red.png + :target: https://odoo-community.org/page/development-status + :alt: Alpha +.. |badge2| image:: https://img.shields.io/badge/licence-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-OCA%2Fpurchase--workflow-lightgray.png?logo=github + :target: https://github.com/OCA/purchase-workflow/tree/14.0/purchase_requisition_sequence_option + :alt: OCA/purchase-workflow +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/purchase-workflow-14-0/purchase-workflow-14-0-purchase_requisition_sequence_option + :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/purchase-workflow&target_branch=14.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module extends module ir_sequence_option and allow you to +provide optional sequences for purchase.requisition documents. + +.. IMPORTANT:: + This is an alpha version, the data model and design can change at any time without warning. + Only for development or testing purpose, do not use in production. + `More details on development status `_ + +**Table of contents** + +.. contents:: + :local: + +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 +~~~~~~~ + +* Ecosoft + +Contributors +~~~~~~~~~~~~ + +* `Ecosoft `__: + + * Pimolnat Suntian + +Maintainers +~~~~~~~~~~~ + +This module is maintained by the OCA. + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +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. + +.. |maintainer-ps-tubtim| image:: https://github.com/ps-tubtim.png?size=40px + :target: https://github.com/ps-tubtim + :alt: ps-tubtim + +Current `maintainer `__: + +|maintainer-ps-tubtim| + +This module is part of the `OCA/purchase-workflow `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/purchase_requisition_sequence_option/__init__.py b/purchase_requisition_sequence_option/__init__.py new file mode 100644 index 00000000000..31660d6a965 --- /dev/null +++ b/purchase_requisition_sequence_option/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from . import models diff --git a/purchase_requisition_sequence_option/__manifest__.py b/purchase_requisition_sequence_option/__manifest__.py new file mode 100644 index 00000000000..5f67e8d5107 --- /dev/null +++ b/purchase_requisition_sequence_option/__manifest__.py @@ -0,0 +1,18 @@ +# Copyright 2023 Ecosoft Co., Ltd. (https://ecosoft.co.th) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +{ + "name": "Purchase Agreement Sequence Option", + "summary": "Manage sequence options for purchase.requisition", + "version": "14.0.1.0.0", + "license": "AGPL-3", + "author": "Ecosoft, Odoo Community Association (OCA)", + "website": "https://github.com/OCA/purchase-workflow", + "category": "Purchase Management", + "depends": ["base_sequence_option", "purchase_requisition"], + "data": ["data/purchase_requisition_sequence_option.xml"], + "demo": ["demo/purchase_requisition_demo_options.xml"], + "development_status": "Alpha", + "maintainers": ["ps-tubtim"], + "installable": True, +} diff --git a/purchase_requisition_sequence_option/data/purchase_requisition_sequence_option.xml b/purchase_requisition_sequence_option/data/purchase_requisition_sequence_option.xml new file mode 100644 index 00000000000..6debc27bc00 --- /dev/null +++ b/purchase_requisition_sequence_option/data/purchase_requisition_sequence_option.xml @@ -0,0 +1,10 @@ + + + + + Purchase Agreement + purchase.requisition + + + + diff --git a/purchase_requisition_sequence_option/demo/purchase_requisition_demo_options.xml b/purchase_requisition_sequence_option/demo/purchase_requisition_demo_options.xml new file mode 100644 index 00000000000..7c38d10b12a --- /dev/null +++ b/purchase_requisition_sequence_option/demo/purchase_requisition_demo_options.xml @@ -0,0 +1,26 @@ + + + + + Purchase Agreement: Option 1 + + TE-1/ + + + + + TE Option 1 + [] + + + + diff --git a/purchase_requisition_sequence_option/models/__init__.py b/purchase_requisition_sequence_option/models/__init__.py new file mode 100644 index 00000000000..922e70ce0da --- /dev/null +++ b/purchase_requisition_sequence_option/models/__init__.py @@ -0,0 +1,4 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from . import purchase_requisition +from . import sequence_option diff --git a/purchase_requisition_sequence_option/models/purchase_requisition.py b/purchase_requisition_sequence_option/models/purchase_requisition.py new file mode 100644 index 00000000000..ddb1211c288 --- /dev/null +++ b/purchase_requisition_sequence_option/models/purchase_requisition.py @@ -0,0 +1,14 @@ +# Copyright 2023 Ecosoft Co., Ltd. (https://ecosoft.co.th) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import models + + +class PurchaseRequisition(models.Model): + _inherit = "purchase.requisition" + + def action_in_progress(self): + self.ensure_one() + seq = self.env["ir.sequence.option.line"].get_sequence(self) + self = self.with_context(sequence_option_id=seq.id) + return super().action_in_progress() diff --git a/purchase_requisition_sequence_option/models/sequence_option.py b/purchase_requisition_sequence_option/models/sequence_option.py new file mode 100644 index 00000000000..39c81536d1d --- /dev/null +++ b/purchase_requisition_sequence_option/models/sequence_option.py @@ -0,0 +1,13 @@ +# Copyright 2023 Ecosoft Co., Ltd. (https://ecosoft.co.th) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import fields, models + + +class IrSequenceOption(models.Model): + _inherit = "ir.sequence.option" + + model = fields.Selection( + selection_add=[("purchase.requisition", "purchase.requisition")], + ondelete={"purchase.requisition": "cascade"}, + ) diff --git a/purchase_requisition_sequence_option/readme/CONTRIBUTORS.rst b/purchase_requisition_sequence_option/readme/CONTRIBUTORS.rst new file mode 100644 index 00000000000..ea63aa7bc15 --- /dev/null +++ b/purchase_requisition_sequence_option/readme/CONTRIBUTORS.rst @@ -0,0 +1,3 @@ +* `Ecosoft `__: + + * Pimolnat Suntian diff --git a/purchase_requisition_sequence_option/readme/DESCRIPTION.rst b/purchase_requisition_sequence_option/readme/DESCRIPTION.rst new file mode 100644 index 00000000000..ad50a2bffef --- /dev/null +++ b/purchase_requisition_sequence_option/readme/DESCRIPTION.rst @@ -0,0 +1,2 @@ +This module extends module ir_sequence_option and allow you to +provide optional sequences for purchase.requisition documents. diff --git a/purchase_requisition_sequence_option/static/description/icon.png b/purchase_requisition_sequence_option/static/description/icon.png new file mode 100644 index 00000000000..3a0328b516c Binary files /dev/null and b/purchase_requisition_sequence_option/static/description/icon.png differ diff --git a/purchase_requisition_sequence_option/static/description/index.html b/purchase_requisition_sequence_option/static/description/index.html new file mode 100644 index 00000000000..caaf811585e --- /dev/null +++ b/purchase_requisition_sequence_option/static/description/index.html @@ -0,0 +1,433 @@ + + + + + + +Purchase Agreement Sequence Option + + + +
+

Purchase Agreement Sequence Option

+ + +

Alpha License: AGPL-3 OCA/purchase-workflow Translate me on Weblate Try me on Runboat

+

This module extends module ir_sequence_option and allow you to +provide optional sequences for purchase.requisition documents.

+
+

Important

+

This is an alpha version, the data model and design can change at any time without warning. +Only for development or testing purpose, do not use in production. +More details on development status

+
+

Table of contents

+ +
+

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

+
    +
  • Ecosoft
  • +
+
+
+

Contributors

+ +
+
+

Maintainers

+

This module is maintained by the OCA.

+Odoo Community Association +

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.

+

Current maintainer:

+

ps-tubtim

+

This module is part of the OCA/purchase-workflow project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ + diff --git a/purchase_requisition_sequence_option/tests/__init__.py b/purchase_requisition_sequence_option/tests/__init__.py new file mode 100644 index 00000000000..a7b38dec6ca --- /dev/null +++ b/purchase_requisition_sequence_option/tests/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from . import test_purchase_requisition_sequence_option diff --git a/purchase_requisition_sequence_option/tests/test_purchase_requisition_sequence_option.py b/purchase_requisition_sequence_option/tests/test_purchase_requisition_sequence_option.py new file mode 100644 index 00000000000..43cd8df2bd2 --- /dev/null +++ b/purchase_requisition_sequence_option/tests/test_purchase_requisition_sequence_option.py @@ -0,0 +1,47 @@ +# Copyright 2023 Ecosoft Co., Ltd. (https://ecosoft.co.th) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo.tests.common import TransactionCase, tagged + + +@tagged("post_install", "-at_install") +class TestPurchaseRequisitionSequenceOption(TransactionCase): + def setUp(self): + super(TestPurchaseRequisitionSequenceOption, self).setUp() + self.PurchaseRequisition = self.env["purchase.requisition"] + self.product_id = self.env.ref("product.product_product_6") + self.te_vals = { + "line_ids": [ + ( + 0, + 0, + { + "product_id": self.product_id.id, + "product_uom_id": self.product_id.uom_po_id.id, + "product_qty": 5.0, + }, + ), + ], + } + self.te_seq_opt = self.env.ref( + "purchase_requisition_sequence_option.purchase_requisition_sequence_option" + ) + + def test_purchase_requisition_sequence_options(self): + """test with and without sequence option activated""" + # With sequence option + self.te_seq_opt.use_sequence_option = True + self.te = self.PurchaseRequisition.create(self.te_vals.copy()) + self.te.action_in_progress() + self.assertIn("TE-1", self.te.name) + self.te_copy = self.te.copy() + self.te_copy.action_in_progress() + self.assertIn("TE-1", self.te_copy.name) + # Without sequence option + self.te_seq_opt.use_sequence_option = False + self.te = self.PurchaseRequisition.create(self.te_vals.copy()) + self.te.action_in_progress() + self.assertNotIn("TE-1", self.te.name) + self.te_copy = self.te.copy() + self.te_copy.action_in_progress() + self.assertNotIn("TE-1", self.te_copy.name) diff --git a/setup/purchase_requisition_sequence_option/odoo/addons/purchase_requisition_sequence_option b/setup/purchase_requisition_sequence_option/odoo/addons/purchase_requisition_sequence_option new file mode 120000 index 00000000000..c2ff5e90029 --- /dev/null +++ b/setup/purchase_requisition_sequence_option/odoo/addons/purchase_requisition_sequence_option @@ -0,0 +1 @@ +../../../../purchase_requisition_sequence_option \ No newline at end of file diff --git a/setup/purchase_requisition_sequence_option/setup.py b/setup/purchase_requisition_sequence_option/setup.py new file mode 100644 index 00000000000..28c57bb6403 --- /dev/null +++ b/setup/purchase_requisition_sequence_option/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)