diff --git a/setup/stock_move_original_date/odoo/addons/stock_move_original_date b/setup/stock_move_original_date/odoo/addons/stock_move_original_date new file mode 120000 index 00000000..93bfe7da --- /dev/null +++ b/setup/stock_move_original_date/odoo/addons/stock_move_original_date @@ -0,0 +1 @@ +../../../../stock_move_original_date \ No newline at end of file diff --git a/setup/stock_move_original_date/setup.py b/setup/stock_move_original_date/setup.py new file mode 100644 index 00000000..28c57bb6 --- /dev/null +++ b/setup/stock_move_original_date/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +) diff --git a/stock_move_original_date/README.rst b/stock_move_original_date/README.rst new file mode 100644 index 00000000..19da188a --- /dev/null +++ b/stock_move_original_date/README.rst @@ -0,0 +1,101 @@ +================================== +Stock Move Original Scheduled Date +================================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:a91a5f87957d82f4234f6892288ae2e2ccf85801d867b7bdd0ec8a017b0ebea9 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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-LGPL--3-blue.png + :target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html + :alt: License: LGPL-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_move_original_date + :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_move_original_date + :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 adds the *Original Date Scheduled* to stock moves. This is useful for +past analysis and warehouse performance reports. + +In standard Odoo, once a transfer is confirmed with an scheduled date, this date +can still change to reflect changes in the planning (e.g. you receive a +notification from your supplier that goods will arrive a couple of days later). +In such situation you lost precious information of the originally planned date +that can be used to compute the real delay in the receipt from your supplier. + +**Table of contents** + +.. contents:: + :local: + +Usage +===== + +#. Create a new transfer and assign an scheduled date. +#. Mark the transfer as to-do. +#. Change the scheduled date. +#. Original scheduled date is kept unchanged. + +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 +~~~~~~~ + +* ForgeFlow + +Contributors +~~~~~~~~~~~~ + +* `ForgeFlow `_: + + * Lois Rilo Antelo + +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-LoisRForgeFlow| image:: https://github.com/LoisRForgeFlow.png?size=40px + :target: https://github.com/LoisRForgeFlow + :alt: LoisRForgeFlow + +Current `maintainer `__: + +|maintainer-LoisRForgeFlow| + +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_move_original_date/__init__.py b/stock_move_original_date/__init__.py new file mode 100644 index 00000000..0650744f --- /dev/null +++ b/stock_move_original_date/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/stock_move_original_date/__manifest__.py b/stock_move_original_date/__manifest__.py new file mode 100644 index 00000000..94e787ce --- /dev/null +++ b/stock_move_original_date/__manifest__.py @@ -0,0 +1,16 @@ +# Copyright 2024 ForgeFlow S.L. (https://www.forgeflow.com) +# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html). + +{ + "name": "Stock Move Original Scheduled Date", + "summary": "adds the Original Date Scheduled to stock moves.", + "version": "16.0.1.0.0", + "category": "Warehouse Management", + "maintainers": ["LoisRForgeFlow"], + "website": "https://github.com/OCA/stock-logistics-workflow", + "author": "ForgeFlow, Odoo Community Association (OCA)", + "license": "LGPL-3", + "installable": True, + "depends": ["stock"], + "data": ["views/stock_move_views.xml", "views/stock_picking_views.xml"], +} diff --git a/stock_move_original_date/i18n/ja.po b/stock_move_original_date/i18n/ja.po new file mode 100644 index 00000000..4e44cea0 --- /dev/null +++ b/stock_move_original_date/i18n/ja.po @@ -0,0 +1,48 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * stock_move_original_date +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2026-03-10 05:19+0000\n" +"PO-Revision-Date: 2026-03-10 05:19+0000\n" +"Last-Translator: \n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: stock_move_original_date +#: model:ir.model.fields,field_description:stock_move_original_date.field_stock_move__original_date +msgid "Original Date Scheduled" +msgstr "当初計画日" + +#. module: stock_move_original_date +#: model:ir.model.fields,field_description:stock_move_original_date.field_stock_picking__original_scheduled_date +msgid "Original Scheduled Date" +msgstr "当初計画日" + +#. module: stock_move_original_date +#: model:ir.model.fields,help:stock_move_original_date.field_stock_picking__original_scheduled_date +msgid "" +"Original Scheduled date for the first part of the shipment to be processed " +"at transfer confirmation." +msgstr "出荷の最初の部分が処理される当初の予定日時。" + +#. module: stock_move_original_date +#: model:ir.model.fields,help:stock_move_original_date.field_stock_move__original_date +msgid "Original Scheduled date on the confirmation of the stock move." +msgstr "在庫移動の確認された時点での当初の予定日時。" + +#. module: stock_move_original_date +#: model:ir.model,name:stock_move_original_date.model_stock_move +msgid "Stock Move" +msgstr "在庫移動" + +#. module: stock_move_original_date +#: model:ir.model,name:stock_move_original_date.model_stock_picking +msgid "Transfer" +msgstr "運送" diff --git a/stock_move_original_date/i18n/stock_move_original_date.pot b/stock_move_original_date/i18n/stock_move_original_date.pot new file mode 100644 index 00000000..5f87473f --- /dev/null +++ b/stock_move_original_date/i18n/stock_move_original_date.pot @@ -0,0 +1,46 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * stock_move_original_date +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 15.0\n" +"Report-Msgid-Bugs-To: \n" +"Last-Translator: \n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: stock_move_original_date +#: model:ir.model.fields,field_description:stock_move_original_date.field_stock_move__original_date +msgid "Original Date Scheduled" +msgstr "" + +#. module: stock_move_original_date +#: model:ir.model.fields,field_description:stock_move_original_date.field_stock_picking__original_scheduled_date +msgid "Original Scheduled Date" +msgstr "" + +#. module: stock_move_original_date +#: model:ir.model.fields,help:stock_move_original_date.field_stock_picking__original_scheduled_date +msgid "" +"Original Scheduled date for the first part of the shipment to be processed " +"at transfer confirmation." +msgstr "" + +#. module: stock_move_original_date +#: model:ir.model.fields,help:stock_move_original_date.field_stock_move__original_date +msgid "Original Scheduled date on the confirmation of the stock move." +msgstr "" + +#. module: stock_move_original_date +#: model:ir.model,name:stock_move_original_date.model_stock_move +msgid "Stock Move" +msgstr "" + +#. module: stock_move_original_date +#: model:ir.model,name:stock_move_original_date.model_stock_picking +msgid "Transfer" +msgstr "" diff --git a/stock_move_original_date/models/__init__.py b/stock_move_original_date/models/__init__.py new file mode 100644 index 00000000..a33bde1e --- /dev/null +++ b/stock_move_original_date/models/__init__.py @@ -0,0 +1,2 @@ +from . import stock_move +from . import stock_picking diff --git a/stock_move_original_date/models/stock_move.py b/stock_move_original_date/models/stock_move.py new file mode 100644 index 00000000..12ff84b2 --- /dev/null +++ b/stock_move_original_date/models/stock_move.py @@ -0,0 +1,21 @@ +# Copyright 2024 ForgeFlow S.L. (https://www.forgeflow.com) +# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html). + +from odoo import fields, models + + +class StockMove(models.Model): + _inherit = "stock.move" + + original_date = fields.Datetime( + string="Original Date Scheduled", + readonly=True, + copy=False, + help="Original Scheduled date on the confirmation of the stock move.", + ) + + def _action_confirm(self, merge=True, merge_into=False): + moves = super()._action_confirm(merge=merge, merge_into=merge_into) + for move in moves: + move.original_date = move.date + return moves diff --git a/stock_move_original_date/models/stock_picking.py b/stock_move_original_date/models/stock_picking.py new file mode 100644 index 00000000..ad361180 --- /dev/null +++ b/stock_move_original_date/models/stock_picking.py @@ -0,0 +1,32 @@ +# Copyright 2024 ForgeFlow S.L. (https://www.forgeflow.com) +# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html). + +from odoo import api, fields, models + + +class StockPicking(models.Model): + _inherit = "stock.picking" + + original_scheduled_date = fields.Datetime( + compute="_compute_original_scheduled_date", + store=True, + readonly=True, + tracking=True, + help="Original Scheduled date for the first part of the " + "shipment to be processed at transfer confirmation.", + ) + + @api.depends("move_ids.state", "move_ids.original_date", "move_type") + def _compute_original_scheduled_date(self): + for picking in self: + raw_moves_dates = picking.move_ids.filtered( + lambda move: move.state != "cancel" + ).mapped("original_date") + moves_dates = [] + for md in raw_moves_dates: + if md: + moves_dates.append(md) + if picking.move_type == "direct": + picking.original_scheduled_date = moves_dates and min(moves_dates) + else: + picking.original_scheduled_date = moves_dates and max(moves_dates) diff --git a/stock_move_original_date/readme/CONTRIBUTORS.rst b/stock_move_original_date/readme/CONTRIBUTORS.rst new file mode 100644 index 00000000..d852fb7d --- /dev/null +++ b/stock_move_original_date/readme/CONTRIBUTORS.rst @@ -0,0 +1,3 @@ +* `ForgeFlow `_: + + * Lois Rilo Antelo diff --git a/stock_move_original_date/readme/DESCRIPTION.rst b/stock_move_original_date/readme/DESCRIPTION.rst new file mode 100644 index 00000000..f15638b3 --- /dev/null +++ b/stock_move_original_date/readme/DESCRIPTION.rst @@ -0,0 +1,8 @@ +This module adds the *Original Date Scheduled* to stock moves. This is useful for +past analysis and warehouse performance reports. + +In standard Odoo, once a transfer is confirmed with an scheduled date, this date +can still change to reflect changes in the planning (e.g. you receive a +notification from your supplier that goods will arrive a couple of days later). +In such situation you lost precious information of the originally planned date +that can be used to compute the real delay in the receipt from your supplier. diff --git a/stock_move_original_date/readme/USAGE.rst b/stock_move_original_date/readme/USAGE.rst new file mode 100644 index 00000000..f80e5614 --- /dev/null +++ b/stock_move_original_date/readme/USAGE.rst @@ -0,0 +1,4 @@ +#. Create a new transfer and assign an scheduled date. +#. Mark the transfer as to-do. +#. Change the scheduled date. +#. Original scheduled date is kept unchanged. diff --git a/stock_move_original_date/static/description/icon.png b/stock_move_original_date/static/description/icon.png new file mode 100644 index 00000000..3a0328b5 Binary files /dev/null and b/stock_move_original_date/static/description/icon.png differ diff --git a/stock_move_original_date/static/description/index.html b/stock_move_original_date/static/description/index.html new file mode 100644 index 00000000..c46f749b --- /dev/null +++ b/stock_move_original_date/static/description/index.html @@ -0,0 +1,447 @@ + + + + + +Stock Move Original Scheduled Date + + + +
+

Stock Move Original Scheduled Date

+ + +

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

+

This module adds the Original Date Scheduled to stock moves. This is useful for +past analysis and warehouse performance reports.

+

In standard Odoo, once a transfer is confirmed with an scheduled date, this date +can still change to reflect changes in the planning (e.g. you receive a +notification from your supplier that goods will arrive a couple of days later). +In such situation you lost precious information of the originally planned date +that can be used to compute the real delay in the receipt from your supplier.

+

Table of contents

+ +
+

Usage

+
    +
  1. Create a new transfer and assign an scheduled date.
  2. +
  3. Mark the transfer as to-do.
  4. +
  5. Change the scheduled date.
  6. +
  7. Original scheduled date is kept unchanged.
  8. +
+
+
+

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

+
    +
  • ForgeFlow
  • +
+
+
+

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:

+

LoisRForgeFlow

+

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_move_original_date/tests/__init__.py b/stock_move_original_date/tests/__init__.py new file mode 100644 index 00000000..1c9ed5d0 --- /dev/null +++ b/stock_move_original_date/tests/__init__.py @@ -0,0 +1 @@ +from . import test_stock_move_original_date diff --git a/stock_move_original_date/tests/test_stock_move_original_date.py b/stock_move_original_date/tests/test_stock_move_original_date.py new file mode 100644 index 00000000..e7a63bbc --- /dev/null +++ b/stock_move_original_date/tests/test_stock_move_original_date.py @@ -0,0 +1,87 @@ +# Copyright 2024 ForgeFlow S.L. (https://www.forgeflow.com) +# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html). + +from datetime import datetime, timedelta as td + +from odoo import Command +from odoo.tests import common + + +class TestStockMoveOriginalDate(common.TransactionCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.pickingModel = cls.env["stock.picking"] + + cls.warehouse = cls.env.ref("stock.warehouse0") + cls.picking_type_in = cls.env.ref("stock.picking_type_in") + cls.supplier_location = cls.env.ref("stock.stock_location_suppliers") + cls.stock_location = cls.env.ref("stock.stock_location_stock") + + cls.product_1 = cls.env["product.product"].create( + {"name": "test", "type": "product"} + ) + + cls.comparison_delta = td(seconds=1) + cls.today = datetime.today() + cls.tomorrow = cls.today + td(1) + cls.day_2 = cls.today + td(2) + + @classmethod + def create_picking_in(cls, product, date_move, qty=10.0): + picking = cls.pickingModel.create( + { + "picking_type_id": cls.picking_type_in.id, + "location_id": cls.supplier_location.id, + "location_dest_id": cls.stock_location.id, + "scheduled_date": date_move, + "move_ids": [ + Command.create( + { + "name": "Test move", + "product_id": product.id, + "date": date_move, + "product_uom": product.uom_id.id, + "product_uom_qty": qty, + "location_id": cls.supplier_location.id, + "location_dest_id": cls.stock_location.id, + } + ) + ], + } + ) + return picking + + @classmethod + def _validate_picking(cls, picking): + for line in picking.move_ids: + line.quantity_done = line.product_uom_qty + picking._action_done() + + def test_01_original_date_stored(self): + picking = self.create_picking_in(self.product_1, self.tomorrow) + self.assertTrue(picking.scheduled_date) + self.assertFalse(picking.original_scheduled_date) + move = picking.move_ids + self.assertTrue(move.date) + self.assertFalse(move.original_date) + picking.action_confirm() + self.assertTrue(picking.original_scheduled_date) + self.assertEqual(picking.scheduled_date, picking.original_scheduled_date) + self.assertTrue(move.original_date) + self.assertEqual(move.date, move.original_date) + move.date = self.day_2 + picking.action_assign() + self.assertEqual(picking.original_scheduled_date, self.tomorrow) + self.assertEqual(picking.scheduled_date, self.day_2) + self.assertEqual(move.original_date, self.tomorrow) + self.assertEqual(move.date, self.day_2) + # Validating the picking update `date` (date done now) but not `original_date` + self._validate_picking(picking) + self.assertAlmostEqual( + picking.original_scheduled_date, self.tomorrow, delta=self.comparison_delta + ) + self.assertAlmostEqual( + move.original_date, self.tomorrow, delta=self.comparison_delta + ) + self.assertAlmostEqual(move.date, self.today, delta=self.comparison_delta) diff --git a/stock_move_original_date/views/stock_move_views.xml b/stock_move_original_date/views/stock_move_views.xml new file mode 100644 index 00000000..dffeb57f --- /dev/null +++ b/stock_move_original_date/views/stock_move_views.xml @@ -0,0 +1,27 @@ + + + + + stock.move.tree - stock_move_original_date + stock.move + + + + + + + + + + stock.move.form - stock_move_original_date + stock.move + + + + + + + + + diff --git a/stock_move_original_date/views/stock_picking_views.xml b/stock_move_original_date/views/stock_picking_views.xml new file mode 100644 index 00000000..8ab9c7c6 --- /dev/null +++ b/stock_move_original_date/views/stock_picking_views.xml @@ -0,0 +1,23 @@ + + + + + + stock.picking.form - stock_move_original_date + stock.picking + + + + + + + + + + + +