diff --git a/purchase_order_sequence_option/README.rst b/purchase_order_sequence_option/README.rst new file mode 100644 index 00000000000..0e51fc697d3 --- /dev/null +++ b/purchase_order_sequence_option/README.rst @@ -0,0 +1,92 @@ +============================== +Purchase Order Sequence Option +============================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:c310119a256f8a592e67230846e5f4ff3390b139b0d17164bbebb524f8dc2fa8 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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_order_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_order_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.order 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_order_sequence_option/__init__.py b/purchase_order_sequence_option/__init__.py new file mode 100644 index 00000000000..31660d6a965 --- /dev/null +++ b/purchase_order_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_order_sequence_option/__manifest__.py b/purchase_order_sequence_option/__manifest__.py new file mode 100644 index 00000000000..93d5c3cb7d2 --- /dev/null +++ b/purchase_order_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 Order Sequence Option", + "summary": "Manage sequence options for purchase.order", + "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"], + "data": ["data/purchase_order_sequence_option.xml"], + "demo": ["demo/purchase_order_demo_options.xml"], + "development_status": "Alpha", + "maintainers": ["ps-tubtim"], + "installable": True, +} diff --git a/purchase_order_sequence_option/data/purchase_order_sequence_option.xml b/purchase_order_sequence_option/data/purchase_order_sequence_option.xml new file mode 100644 index 00000000000..65b57c7b600 --- /dev/null +++ b/purchase_order_sequence_option/data/purchase_order_sequence_option.xml @@ -0,0 +1,10 @@ + + + + + Purchase Order + purchase.order + + + + diff --git a/purchase_order_sequence_option/demo/purchase_order_demo_options.xml b/purchase_order_sequence_option/demo/purchase_order_demo_options.xml new file mode 100644 index 00000000000..02d14204d2c --- /dev/null +++ b/purchase_order_sequence_option/demo/purchase_order_demo_options.xml @@ -0,0 +1,23 @@ + + + + + Purchase Order: Option 1 + + PO-1/ + + + + + PO Option 1 + [] + + + + diff --git a/purchase_order_sequence_option/models/__init__.py b/purchase_order_sequence_option/models/__init__.py new file mode 100644 index 00000000000..a1c4703c15f --- /dev/null +++ b/purchase_order_sequence_option/models/__init__.py @@ -0,0 +1,4 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from . import purchase_order +from . import sequence_option diff --git a/purchase_order_sequence_option/models/purchase_order.py b/purchase_order_sequence_option/models/purchase_order.py new file mode 100644 index 00000000000..9a7633ae132 --- /dev/null +++ b/purchase_order_sequence_option/models/purchase_order.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 api, models + + +class PurchaseOrder(models.Model): + _inherit = "purchase.order" + + @api.model + def create(self, vals): + seq = self.env["ir.sequence.option.line"].get_sequence(self.new(vals)) + self = self.with_context(sequence_option_id=seq.id) + return super().create(vals) diff --git a/purchase_order_sequence_option/models/sequence_option.py b/purchase_order_sequence_option/models/sequence_option.py new file mode 100644 index 00000000000..0ba78a01ccd --- /dev/null +++ b/purchase_order_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.order", "purchase.order")], + ondelete={"purchase.order": "cascade"}, + ) diff --git a/purchase_order_sequence_option/readme/CONTRIBUTORS.rst b/purchase_order_sequence_option/readme/CONTRIBUTORS.rst new file mode 100644 index 00000000000..ea63aa7bc15 --- /dev/null +++ b/purchase_order_sequence_option/readme/CONTRIBUTORS.rst @@ -0,0 +1,3 @@ +* `Ecosoft `__: + + * Pimolnat Suntian diff --git a/purchase_order_sequence_option/readme/DESCRIPTION.rst b/purchase_order_sequence_option/readme/DESCRIPTION.rst new file mode 100644 index 00000000000..a0a85068e22 --- /dev/null +++ b/purchase_order_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.order documents. diff --git a/purchase_order_sequence_option/static/description/icon.png b/purchase_order_sequence_option/static/description/icon.png new file mode 100644 index 00000000000..3a0328b516c Binary files /dev/null and b/purchase_order_sequence_option/static/description/icon.png differ diff --git a/purchase_order_sequence_option/static/description/index.html b/purchase_order_sequence_option/static/description/index.html new file mode 100644 index 00000000000..a970f32da92 --- /dev/null +++ b/purchase_order_sequence_option/static/description/index.html @@ -0,0 +1,433 @@ + + + + + + +Purchase Order Sequence Option + + + +
+

Purchase Order 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.order 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_order_sequence_option/tests/__init__.py b/purchase_order_sequence_option/tests/__init__.py new file mode 100644 index 00000000000..cbdc45a6157 --- /dev/null +++ b/purchase_order_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_order_sequence_option diff --git a/purchase_order_sequence_option/tests/test_purchase_order_sequence_option.py b/purchase_order_sequence_option/tests/test_purchase_order_sequence_option.py new file mode 100644 index 00000000000..ba7ea7202ff --- /dev/null +++ b/purchase_order_sequence_option/tests/test_purchase_order_sequence_option.py @@ -0,0 +1,51 @@ +# Copyright 2023 Ecosoft Co., Ltd. (https://ecosoft.co.th) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from datetime import datetime + +from odoo.tests.common import TransactionCase, tagged +from odoo.tools import DEFAULT_SERVER_DATETIME_FORMAT + + +@tagged("post_install", "-at_install") +class TestPurchaseOrderSequenceOption(TransactionCase): + def setUp(self): + super(TestPurchaseOrderSequenceOption, self).setUp() + self.PurchaseOrder = self.env["purchase.order"] + self.product_id = self.env.ref("product.product_product_6") + self.date_planned = datetime.today().strftime(DEFAULT_SERVER_DATETIME_FORMAT) + self.po_vals = { + "partner_id": self.env.ref("base.res_partner_1").id, + "order_line": [ + ( + 0, + 0, + { + "name": self.product_id.name, + "product_id": self.product_id.id, + "product_qty": 5.0, + "product_uom": self.product_id.uom_po_id.id, + "price_unit": 500.0, + "date_planned": self.date_planned, + }, + ), + ], + } + self.po_seq_opt = self.env.ref( + "purchase_order_sequence_option.purchase_order_sequence_option" + ) + + def test_purchase_order_sequence_options(self): + """test with and without sequence option activated""" + # With sequence option + self.po_seq_opt.use_sequence_option = True + self.po = self.PurchaseOrder.create(self.po_vals.copy()) + self.assertIn("PO-1", self.po.name) + self.po_copy = self.po.copy() + self.assertIn("PO-1", self.po_copy.name) + # Without sequence option + self.po_seq_opt.use_sequence_option = False + self.po = self.PurchaseOrder.create(self.po_vals.copy()) + self.assertNotIn("PO-1", self.po.name) + self.po_copy = self.po.copy() + self.assertNotIn("PO-1", self.po_copy.name) diff --git a/setup/purchase_order_sequence_option/odoo/addons/purchase_order_sequence_option b/setup/purchase_order_sequence_option/odoo/addons/purchase_order_sequence_option new file mode 120000 index 00000000000..74b34a62016 --- /dev/null +++ b/setup/purchase_order_sequence_option/odoo/addons/purchase_order_sequence_option @@ -0,0 +1 @@ +../../../../purchase_order_sequence_option \ No newline at end of file diff --git a/setup/purchase_order_sequence_option/setup.py b/setup/purchase_order_sequence_option/setup.py new file mode 100644 index 00000000000..28c57bb6403 --- /dev/null +++ b/setup/purchase_order_sequence_option/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)