diff --git a/setup/stock_request_sequence_option/odoo/addons/stock_request_sequence_option b/setup/stock_request_sequence_option/odoo/addons/stock_request_sequence_option new file mode 120000 index 000000000..2318ae9cd --- /dev/null +++ b/setup/stock_request_sequence_option/odoo/addons/stock_request_sequence_option @@ -0,0 +1 @@ +../../../../stock_request_sequence_option \ No newline at end of file diff --git a/setup/stock_request_sequence_option/setup.py b/setup/stock_request_sequence_option/setup.py new file mode 100644 index 000000000..28c57bb64 --- /dev/null +++ b/setup/stock_request_sequence_option/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +) diff --git a/stock_request_sequence_option/README.rst b/stock_request_sequence_option/README.rst new file mode 100644 index 000000000..4465032c0 --- /dev/null +++ b/stock_request_sequence_option/README.rst @@ -0,0 +1,92 @@ +============================= +Stock Request Sequence Option +============================= + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:7703e3a9e7129a260c40f5b72b03abc08f95708d90bf974bef2543b0abaa4fcb + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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%2Fstock--logistics--warehouse-lightgray.png?logo=github + :target: https://github.com/OCA/stock-logistics-warehouse/tree/14.0/stock_request_sequence_option + :alt: OCA/stock-logistics-warehouse +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/stock-logistics-warehouse-14-0/stock-logistics-warehouse-14-0-stock_request_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/stock-logistics-warehouse&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 stock request 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/stock-logistics-warehouse `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/stock_request_sequence_option/__init__.py b/stock_request_sequence_option/__init__.py new file mode 100644 index 000000000..31660d6a9 --- /dev/null +++ b/stock_request_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/stock_request_sequence_option/__manifest__.py b/stock_request_sequence_option/__manifest__.py new file mode 100644 index 000000000..35df52d7d --- /dev/null +++ b/stock_request_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": "Stock Request Sequence Option", + "summary": "Manage sequence options for stock request", + "version": "14.0.1.0.0", + "license": "AGPL-3", + "author": "Ecosoft, Odoo Community Association (OCA)", + "website": "https://github.com/OCA/stock-logistics-warehouse", + "category": "Warehouse Management", + "depends": ["base_sequence_option", "stock_request"], + "data": ["data/stock_request_sequence_option.xml"], + "demo": ["demo/stock_request_demo_options.xml"], + "development_status": "Alpha", + "maintainers": ["ps-tubtim"], + "installable": True, +} diff --git a/stock_request_sequence_option/data/stock_request_sequence_option.xml b/stock_request_sequence_option/data/stock_request_sequence_option.xml new file mode 100644 index 000000000..6bfe751ce --- /dev/null +++ b/stock_request_sequence_option/data/stock_request_sequence_option.xml @@ -0,0 +1,16 @@ + + + + + Stock Request + stock.request + + + + + Stock Request Order + stock.request.order + + + + diff --git a/stock_request_sequence_option/demo/stock_request_demo_options.xml b/stock_request_sequence_option/demo/stock_request_demo_options.xml new file mode 100644 index 000000000..2c69c21da --- /dev/null +++ b/stock_request_sequence_option/demo/stock_request_demo_options.xml @@ -0,0 +1,43 @@ + + + + + Stock Request: Option 1 + + SR-1/ + + + Stock Request Order: Option 1 + + SRO-1/ + + + + + SR Option 1 + [] + + + + + SRO Option 1 + [] + + + + diff --git a/stock_request_sequence_option/models/__init__.py b/stock_request_sequence_option/models/__init__.py new file mode 100644 index 000000000..8efcd4488 --- /dev/null +++ b/stock_request_sequence_option/models/__init__.py @@ -0,0 +1,5 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from . import stock_request_order +from . import stock_request +from . import sequence_option diff --git a/stock_request_sequence_option/models/sequence_option.py b/stock_request_sequence_option/models/sequence_option.py new file mode 100644 index 000000000..c56e33fb4 --- /dev/null +++ b/stock_request_sequence_option/models/sequence_option.py @@ -0,0 +1,19 @@ +# 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=[ + ("stock.request", "stock.request"), + ("stock.request.order", "stock.request.order"), + ], + ondelete={ + "stock.request": "cascade", + "stock.request.order": "cascade", + }, + ) diff --git a/stock_request_sequence_option/models/stock_request.py b/stock_request_sequence_option/models/stock_request.py new file mode 100644 index 000000000..3ac4b57b9 --- /dev/null +++ b/stock_request_sequence_option/models/stock_request.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 StockRequest(models.Model): + _inherit = "stock.request" + + @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/stock_request_sequence_option/models/stock_request_order.py b/stock_request_sequence_option/models/stock_request_order.py new file mode 100644 index 000000000..d666cbcd5 --- /dev/null +++ b/stock_request_sequence_option/models/stock_request_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 StockRequestOrder(models.Model): + _inherit = "stock.request.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/stock_request_sequence_option/readme/CONTRIBUTORS.rst b/stock_request_sequence_option/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000..ea63aa7bc --- /dev/null +++ b/stock_request_sequence_option/readme/CONTRIBUTORS.rst @@ -0,0 +1,3 @@ +* `Ecosoft `__: + + * Pimolnat Suntian diff --git a/stock_request_sequence_option/readme/DESCRIPTION.rst b/stock_request_sequence_option/readme/DESCRIPTION.rst new file mode 100644 index 000000000..7d8c6409f --- /dev/null +++ b/stock_request_sequence_option/readme/DESCRIPTION.rst @@ -0,0 +1,2 @@ +This module extends module ir_sequence_option and allow you to +provide optional sequences for stock request documents. diff --git a/stock_request_sequence_option/static/description/icon.png b/stock_request_sequence_option/static/description/icon.png new file mode 100644 index 000000000..3a0328b51 Binary files /dev/null and b/stock_request_sequence_option/static/description/icon.png differ diff --git a/stock_request_sequence_option/static/description/index.html b/stock_request_sequence_option/static/description/index.html new file mode 100644 index 000000000..7afcaaca5 --- /dev/null +++ b/stock_request_sequence_option/static/description/index.html @@ -0,0 +1,433 @@ + + + + + + +Stock Request Sequence Option + + + +
+

Stock Request Sequence Option

+ + +

Alpha License: AGPL-3 OCA/stock-logistics-warehouse Translate me on Weblate Try me on Runboat

+

This module extends module ir_sequence_option and allow you to +provide optional sequences for stock request 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/stock-logistics-warehouse project on GitHub.

+

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

+
+
+
+ + diff --git a/stock_request_sequence_option/tests/__init__.py b/stock_request_sequence_option/tests/__init__.py new file mode 100644 index 000000000..6b54c4631 --- /dev/null +++ b/stock_request_sequence_option/tests/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from . import test_stock_request_sequence_option diff --git a/stock_request_sequence_option/tests/test_stock_request_sequence_option.py b/stock_request_sequence_option/tests/test_stock_request_sequence_option.py new file mode 100644 index 000000000..dfb2a6300 --- /dev/null +++ b/stock_request_sequence_option/tests/test_stock_request_sequence_option.py @@ -0,0 +1,53 @@ +# 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 +from odoo.tests.common import TransactionCase, tagged + + +@tagged("post_install", "-at_install") +class TestStockRequestSequenceOption(TransactionCase): + def setUp(self): + super(TestStockRequestSequenceOption, self).setUp() + self.StockRequest = self.env["stock.request"] + self.StockRequestOrder = self.env["stock.request.order"] + self.product_id = self.env.ref("product.product_product_6") + self.expected_date = fields.Datetime.now() + self.sr_vals = { + "product_id": self.product_id.id, + "product_uom_id": self.product_id.uom_id.id, + "product_uom_qty": 5.0, + "expected_date": self.expected_date, + } + self.sro_vals = { + "expected_date": self.expected_date, + "stock_request_ids": [(0, 0, self.sr_vals)], + } + self.sr_seq_opt = self.env.ref( + "stock_request_sequence_option.stock_request_sequence_option" + ) + self.sro_seq_opt = self.env.ref( + "stock_request_sequence_option.stock_request_order_sequence_option" + ) + + def test_stock_request_sequence_options(self): + """test with and without sequence option activated""" + # With sequence option + self.sr_seq_opt.use_sequence_option = True + self.sr = self.StockRequest.create(self.sr_vals.copy()) + self.assertIn("SR-1", self.sr.name) + # Without sequence option + self.sr_seq_opt.use_sequence_option = False + self.sr = self.StockRequest.create(self.sr_vals.copy()) + self.assertNotIn("SR-1", self.sr.name) + + def test_stock_request_order_sequence_options(self): + """test with and without sequence option activated""" + # With sequence option + self.sro_seq_opt.use_sequence_option = True + self.sro = self.StockRequestOrder.create(self.sro_vals.copy()) + self.assertIn("SRO-1", self.sro.name) + # Without sequence option + self.sro_seq_opt.use_sequence_option = False + self.sro = self.StockRequestOrder.create(self.sro_vals.copy()) + self.assertNotIn("SRO-1", self.sro.name)