diff --git a/stock_release_channel_process_end_time/README.rst b/stock_release_channel_process_end_time/README.rst index 09ea94209e..cea8f0e0cc 100644 --- a/stock_release_channel_process_end_time/README.rst +++ b/stock_release_channel_process_end_time/README.rst @@ -28,10 +28,22 @@ Stock Release Channel Process End Date |badge1| |badge2| |badge3| |badge4| |badge5| -This module allows to set an end time on a release channel that will be transmitted on -related stock pickings (on scheduled date) when the channel awakes. +This module allows to configure an end time on a release channel that will become the channel end date when the channel awakes. This process end date specify when all the work in the channel should be finalized. +Note: ensure to configure the timezone on the address of the warehouse to have the right time to datetime conversion. + +The channel process end date can be propagated to the generated pickings in order to solve two challenges: + +- You expect to view the stock pickings in the same order as the the one you + have set as process end date on the release channel. This way you can easily + manage the deliveries in the same order as the one expected by the planned + release channels. + +- You expect to set as deadline of your released move operations the process + end date of the release channel. This is useful to ensure that move created + when releasing deliveries get the same deadline as the one set on the + release channel. This is also required to allow the merge of move operations + generated for the same product, location in the same stock picking. -That allows to use Odoo core sorting feature on stock pickings level. **Table of contents** @@ -41,6 +53,8 @@ That allows to use Odoo core sorting feature on stock pickings level. Usage ===== +Assign the release channel's process end date to the pickings as scheduled date: + #. Assign a timezone on the Warehouse address if defined and if needed If you have a lot of warehouses in the same timezone, you can also define the timezone on the company partner. @@ -54,6 +68,9 @@ Usage #. Wake up the channel #. The assigned pickings have their scheduled date set at the next end time. (if enabled "Update Scheduled Date" config) +When the assigned pickings are released, the move date deadline is set to the scheduled date +into the pickings generated by the release process. + Known issues / Roadmap ====================== diff --git a/stock_release_channel_process_end_time/models/__init__.py b/stock_release_channel_process_end_time/models/__init__.py index b2326b5874..f158ddf090 100644 --- a/stock_release_channel_process_end_time/models/__init__.py +++ b/stock_release_channel_process_end_time/models/__init__.py @@ -1,3 +1,4 @@ from . import stock_picking from . import stock_release_channel from . import res_config_settings +from . import stock_move diff --git a/stock_release_channel_process_end_time/models/stock_move.py b/stock_release_channel_process_end_time/models/stock_move.py new file mode 100644 index 0000000000..03e87e7ac3 --- /dev/null +++ b/stock_release_channel_process_end_time/models/stock_move.py @@ -0,0 +1,26 @@ +# Copyright 2024 ACSONE SA/NV (https://acsone.eu) +# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html). + +from odoo import models + + +class StockMove(models.Model): + _inherit = "stock.move" + + def _prepare_procurement_values(self): + values = super()._prepare_procurement_values() + if ( + self.picking_id.picking_type_code == "outgoing" + and self.picking_id.release_channel_id.process_end_date + and bool( + self.env["ir.config_parameter"] + .sudo() + .get_param( + "stock_release_channel_process_end_time.stock_release_use_channel_end_date" + ) + ) + ): + values[ + "date_deadline" + ] = self.picking_id.release_channel_id.process_end_date + return values diff --git a/stock_release_channel_process_end_time/readme/DESCRIPTION.rst b/stock_release_channel_process_end_time/readme/DESCRIPTION.rst index b52c964d3d..ef9a3b80ce 100644 --- a/stock_release_channel_process_end_time/readme/DESCRIPTION.rst +++ b/stock_release_channel_process_end_time/readme/DESCRIPTION.rst @@ -1,4 +1,16 @@ -This module allows to set an end time on a release channel that will be transmitted on -related stock pickings (on scheduled date) when the channel awakes. +This module allows to configure an end time on a release channel that will become the channel end date when the channel awakes. This process end date specify when all the work in the channel should be finalized. +Note: ensure to configure the timezone on the address of the warehouse to have the right time to datetime conversion. + +The channel process end date can be propagated to the generated pickings in order to solve two challenges: + +- You expect to view the stock pickings in the same order as the the one you + have set as process end date on the release channel. This way you can easily + manage the deliveries in the same order as the one expected by the planned + release channels. + +- You expect to set as deadline of your released move operations the process + end date of the release channel. This is useful to ensure that move created + when releasing deliveries get the same deadline as the one set on the + release channel. This is also required to allow the merge of move operations + generated for the same product, location in the same stock picking. -That allows to use Odoo core sorting feature on stock pickings level. diff --git a/stock_release_channel_process_end_time/readme/USAGE.rst b/stock_release_channel_process_end_time/readme/USAGE.rst index 3ddf7ed70b..2c77f9e2b6 100644 --- a/stock_release_channel_process_end_time/readme/USAGE.rst +++ b/stock_release_channel_process_end_time/readme/USAGE.rst @@ -1,3 +1,5 @@ +Assign the release channel's process end date to the pickings as scheduled date: + #. Assign a timezone on the Warehouse address if defined and if needed If you have a lot of warehouses in the same timezone, you can also define the timezone on the company partner. @@ -10,3 +12,6 @@ #. Set an end time #. Wake up the channel #. The assigned pickings have their scheduled date set at the next end time. (if enabled "Update Scheduled Date" config) + +When the assigned pickings are released, the move date deadline is set to the scheduled date +into the pickings generated by the release process. diff --git a/stock_release_channel_process_end_time/static/description/index.html b/stock_release_channel_process_end_time/static/description/index.html index caa196fe29..bcbe266eaf 100644 --- a/stock_release_channel_process_end_time/static/description/index.html +++ b/stock_release_channel_process_end_time/static/description/index.html @@ -1,3 +1,4 @@ + @@ -369,9 +370,20 @@

Stock Release Channel Process End Date

!! source digest: sha256:22bfc4855a34d9fdb1e2a6dcb73c106e67bbfd83f01c0736a8edf05c10eedc45 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->

Beta License: AGPL-3 OCA/wms Translate me on Weblate Try me on Runboat

-

This module allows to set an end time on a release channel that will be transmitted on -related stock pickings (on scheduled date) when the channel awakes.

-

That allows to use Odoo core sorting feature on stock pickings level.

+

This module allows to configure an end time on a release channel that will become the channel end date when the channel awakes. This process end date specify when all the work in the channel should be finalized. +Note: ensure to configure the timezone on the address of the warehouse to have the right time to datetime conversion.

+

The channel process end date can be propagated to the generated pickings in order to solve two challenges:

+

Table of contents

Usage

+

Assign the release channel’s process end date to the pickings as scheduled date:

  1. Assign a timezone on the Warehouse address if defined and if needed If you have a lot of warehouses in the same timezone, you can also define @@ -401,6 +414,8 @@

    Usage

  2. Wake up the channel
  3. The assigned pickings have their scheduled date set at the next end time. (if enabled “Update Scheduled Date” config)
+

When the assigned pickings are released, the move date deadline is set to the scheduled date +into the pickings generated by the release process.

Known issues / Roadmap

diff --git a/stock_release_channel_process_end_time/tests/test_release_end_date.py b/stock_release_channel_process_end_time/tests/test_release_end_date.py index 36707f16d8..6fd5bad09a 100644 --- a/stock_release_channel_process_end_time/tests/test_release_end_date.py +++ b/stock_release_channel_process_end_time/tests/test_release_end_date.py @@ -161,6 +161,45 @@ def test_picking_scheduled_date(self): "2023-01-27 15:00:00", fields.Datetime.to_string(move.date) ) + @freeze_time("2023-01-27 10:00:00") + def test_channel_end_date_as_move_date_deadline_on_moves_created_by_release(self): + """ + Check that the process end date is set as the move date deadline on + moves created by the release of a shipping (and also on the generated pick + itself). + """ + self.env["ir.config_parameter"].sudo().set_param( + "stock_release_channel_process_end_time.stock_release_use_channel_end_date", + True, + ) + # Remove existing jobs as some already exists to assign pickings to channel + jobs_before = self.env["queue.job"].search([]) + jobs_before.unlink() + # Set the end time + self.channel.process_end_time = 23.0 + channel = self.channel.with_context(queue_job__no_delay=True) + # Asleep the release channel to void the process end date + channel.action_sleep() + new_pickings = channel.picking_ids.move_ids.move_orig_ids.picking_id + self.assertFalse(new_pickings) + channel.invalidate_recordset() + channel.action_wake_up() + self._update_qty_in_location(self.loc_bin1, self.product1, 100.0) + self._update_qty_in_location(self.loc_bin1, self.product2, 100.0) + pickings = channel.picking_ids + pickings.env.invalidate_all() + # release the pickings + pickings.release_available_to_promise() + # get the moves created by the release + new_pickings = pickings.move_ids.move_orig_ids.picking_id + self.assertTrue(new_pickings) + # check that the picking schedule date is set to the process end date + for picking in new_pickings: + self.assertEqual( + "2023-01-27 23:00:00", + fields.Datetime.to_string(picking.move_ids[0].date_deadline), + ) + def test_can_edit_time(self): user = self.env.ref("base.user_demo") group = self.env.ref("stock.group_stock_manager")