diff --git a/stock_picking_date_deadline_syncs_scheduled_date/README.rst b/stock_picking_date_deadline_syncs_scheduled_date/README.rst new file mode 100644 index 000000000000..dcb862d8f0e9 --- /dev/null +++ b/stock_picking_date_deadline_syncs_scheduled_date/README.rst @@ -0,0 +1,126 @@ +================================================ +Stock Picking Date Deadline syncs Scheduled Date +================================================ + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:44a9637ff76e9757f0592ae699fc9ec1b7013d9ca456f4be3248d1ee3b71a2a3 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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-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/18.0/stock_picking_date_deadline_syncs_scheduled_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-18-0/stock-logistics-workflow-18-0-stock_picking_date_deadline_syncs_scheduled_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=18.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module extends the functionality of Stock Picking dates to align +the Deadline Date field with the Planned Date field in the first +instance and to allow the Planned Date field to be used as a reference +field when preparing deliveries. + +As usual, allows the Planned Date field to be freely changed without +affecting the Deadline Date field, but if the Deadline date field is +changed on Pickings through another module, the Planned Date field on +the Picking will also be updated to the Deadline Date. + +.. 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: + +Use Cases / Context +=================== + +This module has been developed to allow the Scheduled date field on +Pickings (and Date on moves) to be used as a reference field for +planning purposes when products have to be shipped on the same day that +needs to be delivered. + +Usage +===== + +To use this module, you need to: + +1. Sell a storable product to create pickings or create a new delivery. +2. Confirm the sale or picking. +3. Add the Commitment date to sale or Deadline date on stock moves. This + will change deadline date and scheduled date of your pickings. +4. Change again Commitment date on sales or Deadline date on stock + moves. This will change deadline date and scheduled date of your + pickings. +5. Go to the picking and change Schedule date if you want to make a + rescheduling. + +Known issues / Roadmap +====================== + +To be able to configure the Planned date some days before Deadline date. + +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 +------- + +* Moduon + +Contributors +------------ + +- Eduardo de Miguel (`Moduon `__) +- Rafael Blasco (`Moduon `__) + +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-Shide| image:: https://github.com/Shide.png?size=40px + :target: https://github.com/Shide + :alt: Shide + +Current `maintainer `__: + +|maintainer-Shide| + +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_date_deadline_syncs_scheduled_date/__init__.py b/stock_picking_date_deadline_syncs_scheduled_date/__init__.py new file mode 100644 index 000000000000..0650744f6bc6 --- /dev/null +++ b/stock_picking_date_deadline_syncs_scheduled_date/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/stock_picking_date_deadline_syncs_scheduled_date/__manifest__.py b/stock_picking_date_deadline_syncs_scheduled_date/__manifest__.py new file mode 100644 index 000000000000..85fd02fdaab0 --- /dev/null +++ b/stock_picking_date_deadline_syncs_scheduled_date/__manifest__.py @@ -0,0 +1,17 @@ +# Copyright 2024 Moduon Team S.L. +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl-3.0) + +{ + "name": "Stock Picking Date Deadline syncs Scheduled Date", + "summary": "Sync Scheduled Date with Date Deadline in Stock Picking", + "version": "18.0.1.0.0", + "development_status": "Alpha", + "category": "Inventory/Inventory", + "website": "https://github.com/OCA/stock-logistics-workflow", + "author": "Moduon, Odoo Community Association (OCA)", + "maintainers": ["Shide"], + "license": "LGPL-3", + "application": False, + "installable": True, + "depends": ["stock"], +} diff --git a/stock_picking_date_deadline_syncs_scheduled_date/i18n/it.po b/stock_picking_date_deadline_syncs_scheduled_date/i18n/it.po new file mode 100644 index 000000000000..47a5c686b51c --- /dev/null +++ b/stock_picking_date_deadline_syncs_scheduled_date/i18n/it.po @@ -0,0 +1,22 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * stock_picking_date_deadline_syncs_scheduled_date +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2024-06-24 13:39+0000\n" +"Last-Translator: mymage \n" +"Language-Team: none\n" +"Language: it\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Weblate 4.17\n" + +#. module: stock_picking_date_deadline_syncs_scheduled_date +#: model:ir.model,name:stock_picking_date_deadline_syncs_scheduled_date.model_stock_move +msgid "Stock Move" +msgstr "Movimento di magazzino" diff --git a/stock_picking_date_deadline_syncs_scheduled_date/i18n/stock_picking_date_deadline_syncs_scheduled_date.pot b/stock_picking_date_deadline_syncs_scheduled_date/i18n/stock_picking_date_deadline_syncs_scheduled_date.pot new file mode 100644 index 000000000000..37c57e050620 --- /dev/null +++ b/stock_picking_date_deadline_syncs_scheduled_date/i18n/stock_picking_date_deadline_syncs_scheduled_date.pot @@ -0,0 +1,19 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * stock_picking_date_deadline_syncs_scheduled_date +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.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_picking_date_deadline_syncs_scheduled_date +#: model:ir.model,name:stock_picking_date_deadline_syncs_scheduled_date.model_stock_move +msgid "Stock Move" +msgstr "" diff --git a/stock_picking_date_deadline_syncs_scheduled_date/models/__init__.py b/stock_picking_date_deadline_syncs_scheduled_date/models/__init__.py new file mode 100644 index 000000000000..6bda2d2428e0 --- /dev/null +++ b/stock_picking_date_deadline_syncs_scheduled_date/models/__init__.py @@ -0,0 +1 @@ +from . import stock_move diff --git a/stock_picking_date_deadline_syncs_scheduled_date/models/stock_move.py b/stock_picking_date_deadline_syncs_scheduled_date/models/stock_move.py new file mode 100644 index 000000000000..036e1b3040b1 --- /dev/null +++ b/stock_picking_date_deadline_syncs_scheduled_date/models/stock_move.py @@ -0,0 +1,13 @@ +# Copyright 2024 Moduon Team S.L. +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl-3.0) + +from odoo import models + + +class StockMove(models.Model): + _inherit = "stock.move" + + def write(self, values): + if values.get("date_deadline"): + values.update({"date": values["date_deadline"]}) + return super().write(values) diff --git a/stock_picking_date_deadline_syncs_scheduled_date/pyproject.toml b/stock_picking_date_deadline_syncs_scheduled_date/pyproject.toml new file mode 100644 index 000000000000..4231d0cccb3d --- /dev/null +++ b/stock_picking_date_deadline_syncs_scheduled_date/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/stock_picking_date_deadline_syncs_scheduled_date/readme/CONTEXT.md b/stock_picking_date_deadline_syncs_scheduled_date/readme/CONTEXT.md new file mode 100644 index 000000000000..c16234e8b726 --- /dev/null +++ b/stock_picking_date_deadline_syncs_scheduled_date/readme/CONTEXT.md @@ -0,0 +1 @@ +This module has been developed to allow the Scheduled date field on Pickings (and Date on moves) to be used as a reference field for planning purposes when products have to be shipped on the same day that needs to be delivered. diff --git a/stock_picking_date_deadline_syncs_scheduled_date/readme/CONTRIBUTORS.md b/stock_picking_date_deadline_syncs_scheduled_date/readme/CONTRIBUTORS.md new file mode 100644 index 000000000000..0ca1be35b55c --- /dev/null +++ b/stock_picking_date_deadline_syncs_scheduled_date/readme/CONTRIBUTORS.md @@ -0,0 +1,2 @@ +- Eduardo de Miguel ([Moduon](https://www.moduon.team/)) +- Rafael Blasco ([Moduon](https://www.moduon.team/)) diff --git a/stock_picking_date_deadline_syncs_scheduled_date/readme/DESCRIPTION.md b/stock_picking_date_deadline_syncs_scheduled_date/readme/DESCRIPTION.md new file mode 100644 index 000000000000..12f09ec6ae87 --- /dev/null +++ b/stock_picking_date_deadline_syncs_scheduled_date/readme/DESCRIPTION.md @@ -0,0 +1,3 @@ +This module extends the functionality of Stock Picking dates to align the Deadline Date field with the Planned Date field in the first instance and to allow the Planned Date field to be used as a reference field when preparing deliveries. + +As usual, allows the Planned Date field to be freely changed without affecting the Deadline Date field, but if the Deadline date field is changed on Pickings through another module, the Planned Date field on the Picking will also be updated to the Deadline Date. diff --git a/stock_picking_date_deadline_syncs_scheduled_date/readme/ROADMAP.md b/stock_picking_date_deadline_syncs_scheduled_date/readme/ROADMAP.md new file mode 100644 index 000000000000..b651707af918 --- /dev/null +++ b/stock_picking_date_deadline_syncs_scheduled_date/readme/ROADMAP.md @@ -0,0 +1 @@ +To be able to configure the Planned date some days before Deadline date. diff --git a/stock_picking_date_deadline_syncs_scheduled_date/readme/USAGE.md b/stock_picking_date_deadline_syncs_scheduled_date/readme/USAGE.md new file mode 100644 index 000000000000..9a6c902839ed --- /dev/null +++ b/stock_picking_date_deadline_syncs_scheduled_date/readme/USAGE.md @@ -0,0 +1,7 @@ +To use this module, you need to: + +1. Sell a storable product to create pickings or create a new delivery. +2. Confirm the sale or picking. +3. Add the Commitment date to sale or Deadline date on stock moves. This will change deadline date and scheduled date of your pickings. +4. Change again Commitment date on sales or Deadline date on stock moves. This will change deadline date and scheduled date of your pickings. +5. Go to the picking and change Schedule date if you want to make a rescheduling. diff --git a/stock_picking_date_deadline_syncs_scheduled_date/static/description/icon.png b/stock_picking_date_deadline_syncs_scheduled_date/static/description/icon.png new file mode 100644 index 000000000000..3a0328b516c4 Binary files /dev/null and b/stock_picking_date_deadline_syncs_scheduled_date/static/description/icon.png differ diff --git a/stock_picking_date_deadline_syncs_scheduled_date/static/description/index.html b/stock_picking_date_deadline_syncs_scheduled_date/static/description/index.html new file mode 100644 index 000000000000..314e96593a44 --- /dev/null +++ b/stock_picking_date_deadline_syncs_scheduled_date/static/description/index.html @@ -0,0 +1,468 @@ + + + + + +Stock Picking Date Deadline syncs Scheduled Date + + + +
+

Stock Picking Date Deadline syncs Scheduled Date

+ + +

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

+

This module extends the functionality of Stock Picking dates to align +the Deadline Date field with the Planned Date field in the first +instance and to allow the Planned Date field to be used as a reference +field when preparing deliveries.

+

As usual, allows the Planned Date field to be freely changed without +affecting the Deadline Date field, but if the Deadline date field is +changed on Pickings through another module, the Planned Date field on +the Picking will also be updated to the Deadline Date.

+
+

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

+ +
+

Use Cases / Context

+

This module has been developed to allow the Scheduled date field on +Pickings (and Date on moves) to be used as a reference field for +planning purposes when products have to be shipped on the same day that +needs to be delivered.

+
+
+

Usage

+

To use this module, you need to:

+
    +
  1. Sell a storable product to create pickings or create a new delivery.
  2. +
  3. Confirm the sale or picking.
  4. +
  5. Add the Commitment date to sale or Deadline date on stock moves. This +will change deadline date and scheduled date of your pickings.
  6. +
  7. Change again Commitment date on sales or Deadline date on stock +moves. This will change deadline date and scheduled date of your +pickings.
  8. +
  9. Go to the picking and change Schedule date if you want to make a +rescheduling.
  10. +
+
+
+

Known issues / Roadmap

+

To be able to configure the Planned date some days before Deadline date.

+
+
+

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

+
    +
  • Moduon
  • +
+
+
+

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:

+

Shide

+

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_date_deadline_syncs_scheduled_date/tests/__init__.py b/stock_picking_date_deadline_syncs_scheduled_date/tests/__init__.py new file mode 100644 index 000000000000..652b2b58ec2c --- /dev/null +++ b/stock_picking_date_deadline_syncs_scheduled_date/tests/__init__.py @@ -0,0 +1 @@ +from . import test_date_deadline_sync diff --git a/stock_picking_date_deadline_syncs_scheduled_date/tests/test_date_deadline_sync.py b/stock_picking_date_deadline_syncs_scheduled_date/tests/test_date_deadline_sync.py new file mode 100644 index 000000000000..7ce4a5ced12a --- /dev/null +++ b/stock_picking_date_deadline_syncs_scheduled_date/tests/test_date_deadline_sync.py @@ -0,0 +1,97 @@ +# Copyright 2024 Moduon Team S.L. +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl-3.0) + +from datetime import datetime, timedelta + +from odoo.tests.common import TransactionCase + + +class TestDateDeadlineSync(TransactionCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.product = cls.env["product.product"].create( + {"name": "Test Product", "type": "consu"} + ) + cls.partner = cls.env["res.partner"].create({"name": "Test Partner"}) + stock_location_id = cls.env.ref("stock.stock_location_stock").id + stock_location_customers_id = cls.env.ref("stock.stock_location_customers").id + stock_location_suppliers_id = cls.env.ref("stock.stock_location_suppliers").id + cls.out_picking = cls.env["stock.picking"].create( + { + "partner_id": cls.partner.id, + "picking_type_id": cls.env.ref("stock.picking_type_out").id, + "location_id": stock_location_id, + "location_dest_id": stock_location_customers_id, + "move_ids": [ + ( + 0, + 0, + { + "name": "Test line", + "product_id": cls.product.id, + "product_uom_qty": 1.0, + "product_uom": cls.product.uom_id.id, + "location_id": stock_location_id, + "location_dest_id": stock_location_customers_id, + }, + ) + ], + } + ) + cls.in_picking = cls.env["stock.picking"].create( + { + "partner_id": cls.partner.id, + "picking_type_id": cls.env.ref("stock.picking_type_in").id, + "location_id": stock_location_suppliers_id, + "location_dest_id": stock_location_id, + "move_ids": [ + ( + 0, + 0, + { + "name": "Test line", + "product_id": cls.product.id, + "product_uom_qty": 1.0, + "product_uom": cls.product.uom_id.id, + "location_id": stock_location_suppliers_id, + "location_dest_id": stock_location_id, + }, + ) + ], + } + ) + + def _test_deadline_changes(self, picking): + init_deadline = datetime.now() + timedelta(days=5) + move = picking.move_ids + move.date_deadline = init_deadline + move.date = init_deadline + picking.action_assign() + # Change Delivery Date on Sale Order > Change Scheduled and Deadline dates + self.assertEqual(picking.date_deadline, init_deadline) + self.assertEqual(move.date_deadline, init_deadline) + self.assertEqual(picking.scheduled_date, init_deadline) + self.assertEqual(move.date, init_deadline) + # Change Scheduled on picking > no change on Date Deadline + re_scheduled_date = init_deadline + timedelta(days=10) + picking.scheduled_date = re_scheduled_date + self.assertEqual(picking.date_deadline, init_deadline) + self.assertEqual(move.date_deadline, init_deadline) + self.assertEqual(picking.scheduled_date, re_scheduled_date) + self.assertEqual(move.date, re_scheduled_date) + # Change Delivery Date on Sale Order > Change Scheduled and Deadline dates + final_deadline = init_deadline + timedelta(days=15) + move.date_deadline = final_deadline + self.assertEqual(picking.date_deadline, final_deadline) + self.assertEqual(move.date_deadline, final_deadline) + self.assertEqual(picking.scheduled_date, final_deadline) + self.assertEqual(move.date, final_deadline) + + def test_outgoing_date_sync(self): + """Test Outgoing shipments deadline date syncs scheduled date""" + self._test_deadline_changes(self.out_picking) + + def test_incoming_date_sync(self): + """Test Incoming shipments deadline date syncs scheduled date""" + self._test_deadline_changes(self.in_picking)