diff --git a/setup/stock_picking_auto_create_lot_sequence/odoo/addons/stock_picking_auto_create_lot_sequence b/setup/stock_picking_auto_create_lot_sequence/odoo/addons/stock_picking_auto_create_lot_sequence new file mode 120000 index 00000000..d850b9fe --- /dev/null +++ b/setup/stock_picking_auto_create_lot_sequence/odoo/addons/stock_picking_auto_create_lot_sequence @@ -0,0 +1 @@ +../../../../stock_picking_auto_create_lot_sequence \ No newline at end of file diff --git a/setup/stock_picking_auto_create_lot_sequence/setup.py b/setup/stock_picking_auto_create_lot_sequence/setup.py new file mode 100644 index 00000000..28c57bb6 --- /dev/null +++ b/setup/stock_picking_auto_create_lot_sequence/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +) diff --git a/stock_picking_auto_create_lot_sequence/README.rst b/stock_picking_auto_create_lot_sequence/README.rst new file mode 100644 index 00000000..2efe5b21 --- /dev/null +++ b/stock_picking_auto_create_lot_sequence/README.rst @@ -0,0 +1,71 @@ +====================================== +Stock Picking Auto Create Lot Sequence +====================================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:a9a6e7e2ceaf2cf58433b95148d16e50b1fb860af3ee29423c614f182b9a66c1 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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/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--workflow-lightgray.png?logo=github + :target: https://github.com/OCA/stock-logistics-workflow/tree/16.0/stock_picking_auto_create_lot_sequence + :alt: OCA/stock-logistics-workflow +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/stock-logistics-workflow-16-0/stock-logistics-workflow-16-0-stock_picking_auto_create_lot_sequence + :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-workflow&target_branch=16.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module acts as a bridge between the stock_picking_auto_create_lot and product_lot_sequence modules. + +**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 +~~~~~~~ + +* Quartile + +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. + +This module is part of the `OCA/stock-logistics-workflow `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/stock_picking_auto_create_lot_sequence/__init__.py b/stock_picking_auto_create_lot_sequence/__init__.py new file mode 100644 index 00000000..0650744f --- /dev/null +++ b/stock_picking_auto_create_lot_sequence/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/stock_picking_auto_create_lot_sequence/__manifest__.py b/stock_picking_auto_create_lot_sequence/__manifest__.py new file mode 100644 index 00000000..17147335 --- /dev/null +++ b/stock_picking_auto_create_lot_sequence/__manifest__.py @@ -0,0 +1,11 @@ +# Copyright 2024 Quartile (https://www.quartile.co) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +{ + "name": "Stock Picking Auto Create Lot Sequence", + "version": "16.0.1.0.0", + "license": "AGPL-3", + "author": "Quartile, Odoo Community Association (OCA)", + "website": "https://github.com/OCA/stock-logistics-workflow", + "depends": ["product_lot_sequence", "stock_picking_auto_create_lot"], +} diff --git a/stock_picking_auto_create_lot_sequence/models/__init__.py b/stock_picking_auto_create_lot_sequence/models/__init__.py new file mode 100644 index 00000000..431f51c2 --- /dev/null +++ b/stock_picking_auto_create_lot_sequence/models/__init__.py @@ -0,0 +1 @@ +from . import stock_move_line diff --git a/stock_picking_auto_create_lot_sequence/models/stock_move_line.py b/stock_picking_auto_create_lot_sequence/models/stock_move_line.py new file mode 100644 index 00000000..d95b5617 --- /dev/null +++ b/stock_picking_auto_create_lot_sequence/models/stock_move_line.py @@ -0,0 +1,17 @@ +# Copyright 2024 Quartile (https://www.quartile.co) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import models + + +class StockMoveLine(models.Model): + _inherit = "stock.move.line" + + def _get_lot_sequence(self): + self.ensure_one() + if not self.product_id.lot_sequence_id: + return super()._get_lot_sequence() + seq_policy = self.env["stock.lot"]._get_sequence_policy() + if seq_policy != "product": + return super()._get_lot_sequence() + return self.product_id.lot_sequence_id._next() diff --git a/stock_picking_auto_create_lot_sequence/readme/DESCRIPTION.rst b/stock_picking_auto_create_lot_sequence/readme/DESCRIPTION.rst new file mode 100644 index 00000000..0c8b1aa1 --- /dev/null +++ b/stock_picking_auto_create_lot_sequence/readme/DESCRIPTION.rst @@ -0,0 +1 @@ +This module acts as a bridge between the stock_picking_auto_create_lot and product_lot_sequence modules. diff --git a/stock_picking_auto_create_lot_sequence/static/description/index.html b/stock_picking_auto_create_lot_sequence/static/description/index.html new file mode 100644 index 00000000..e8ffff05 --- /dev/null +++ b/stock_picking_auto_create_lot_sequence/static/description/index.html @@ -0,0 +1,413 @@ + + + + + +Stock Picking Auto Create Lot Sequence + + + +
+

Stock Picking Auto Create Lot Sequence

+ + +

Beta License: AGPL-3 OCA/stock-logistics-workflow Translate me on Weblate Try me on Runboat

+

This module acts as a bridge between the stock_picking_auto_create_lot and product_lot_sequence modules.

+

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

+
    +
  • Quartile
  • +
+
+
+

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.

+

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

+

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

+
+
+
+ + diff --git a/stock_picking_auto_create_lot_sequence/tests/__init__.py b/stock_picking_auto_create_lot_sequence/tests/__init__.py new file mode 100644 index 00000000..a0302eac --- /dev/null +++ b/stock_picking_auto_create_lot_sequence/tests/__init__.py @@ -0,0 +1 @@ +from . import test_stock_picking_auto_create_lot_sequence diff --git a/stock_picking_auto_create_lot_sequence/tests/test_stock_picking_auto_create_lot_sequence.py b/stock_picking_auto_create_lot_sequence/tests/test_stock_picking_auto_create_lot_sequence.py new file mode 100644 index 00000000..2e01fb40 --- /dev/null +++ b/stock_picking_auto_create_lot_sequence/tests/test_stock_picking_auto_create_lot_sequence.py @@ -0,0 +1,67 @@ +# Copyright 2024 Quartile (https://www.quartile.co) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo.tests.common import Form, TransactionCase + + +class TestStockPickingProductLotSequence(TransactionCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + supplier_location = cls.env.ref("stock.stock_location_suppliers") + stock_location = cls.env.ref("stock.stock_location_stock") + picking_type_in = cls.env.ref("stock.picking_type_in") + picking_type_in.auto_create_lot = True + cls.product = cls.env["product.product"].create( + { + "name": "Test Product", + "type": "product", + "tracking": "serial", + "auto_create_lot": True, + } + ) + cls.product.lot_sequence_id.write( + { + "prefix": "Test/", + "padding": 5, + "number_increment": 1, + "number_next_actual": 1, + } + ) + cls.picking = cls.env["stock.picking"].create( + { + "location_id": supplier_location.id, + "location_dest_id": stock_location.id, + "picking_type_id": picking_type_in.id, + } + ) + cls.env["stock.move"].create( + { + "name": "Test Move", + "product_id": cls.product.id, + "product_uom_qty": 10, + "product_uom": cls.product.uom_id.id, + "picking_id": cls.picking.id, + "location_id": supplier_location.id, + "location_dest_id": stock_location.id, + } + ) + + def test_stock_picking_product_lot_sequence(self): + self.assertTrue(self.product.lot_sequence_id) + next_serial = self.env["stock.lot"]._get_next_serial( + self.env.company, self.product + ) + self.assertRegex(next_serial, r"Test/\d{5}") + self.picking.action_confirm() + self.picking.action_assign() + immediate_wizard = self.picking.button_validate() + self.assertEqual(immediate_wizard.get("res_model"), "stock.immediate.transfer") + immediate_wizard_form = Form( + self.env[immediate_wizard["res_model"]].with_context( + **immediate_wizard["context"] + ) + ).save() + immediate_wizard_form.process() + for move_line in self.picking.move_line_ids: + self.assertRegex(move_line.lot_name, r"Test/\d{5}")