Skip to content

Commit

Permalink
[IMP] stock_release_channel_process_end_time: process_end_date as dat…
Browse files Browse the repository at this point in the history
…e_deadline

Add a new option on the route definition to allow the use of the release channel's process end date as date deadline on stock moves created when releasing deliveries. This is required to allow the merge of generated moves. By default pulled moves keep the date deadline of their destination moves. If different moves for the same product from different sale orders are grouped into the same delivery, you expect that the system will generate only one pick operation. It's only possible if the generated pulled moves have the same date deadline.
  • Loading branch information
lmignon authored and sbejaoui committed Apr 4, 2024
1 parent 38a27aa commit cc59da6
Show file tree
Hide file tree
Showing 7 changed files with 124 additions and 9 deletions.
23 changes: 20 additions & 3 deletions stock_release_channel_process_end_time/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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**

Expand All @@ -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.
Expand All @@ -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
======================

Expand Down
1 change: 1 addition & 0 deletions stock_release_channel_process_end_time/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from . import stock_picking
from . import stock_release_channel
from . import res_config_settings
from . import stock_move
26 changes: 26 additions & 0 deletions stock_release_channel_process_end_time/models/stock_move.py
Original file line number Diff line number Diff line change
@@ -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
18 changes: 15 additions & 3 deletions stock_release_channel_process_end_time/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -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.
5 changes: 5 additions & 0 deletions stock_release_channel_process_end_time/readme/USAGE.rst
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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.
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
Expand Down Expand Up @@ -369,9 +370,20 @@ <h1 class="title">Stock Release Channel Process End Date</h1>
!! source digest: sha256:22bfc4855a34d9fdb1e2a6dcb73c106e67bbfd83f01c0736a8edf05c10eedc45
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/wms/tree/16.0/stock_release_channel_process_end_time"><img alt="OCA/wms" src="https://img.shields.io/badge/github-OCA%2Fwms-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/wms-16-0/wms-16-0-stock_release_channel_process_end_time"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/wms&amp;target_branch=16.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>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.</p>
<p>That allows to use Odoo core sorting feature on stock pickings level.</p>
<p>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.</p>
<p>The channel process end date can be propagated to the generated pickings in order to solve two challenges:</p>
<ul class="simple">
<li>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.</li>
<li>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.</li>
</ul>
<p><strong>Table of contents</strong></p>
<div class="contents local topic" id="contents">
<ul class="simple">
Expand All @@ -388,6 +400,7 @@ <h1 class="title">Stock Release Channel Process End Date</h1>
</div>
<div class="section" id="usage">
<h1><a class="toc-backref" href="#toc-entry-1">Usage</a></h1>
<p>Assign the release channel’s process end date to the pickings as scheduled date:</p>
<ol class="arabic simple">
<li>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
Expand All @@ -401,6 +414,8 @@ <h1><a class="toc-backref" href="#toc-entry-1">Usage</a></h1>
<li>Wake up the channel</li>
<li>The assigned pickings have their scheduled date set at the next end time. (if enabled “Update Scheduled Date” config)</li>
</ol>
<p>When the assigned pickings are released, the move date deadline is set to the scheduled date
into the pickings generated by the release process.</p>
</div>
<div class="section" id="known-issues-roadmap">
<h1><a class="toc-backref" href="#toc-entry-2">Known issues / Roadmap</a></h1>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit cc59da6

Please sign in to comment.