Skip to content

Commit

Permalink
Merge PR #827 into 16.0
Browse files Browse the repository at this point in the history
Signed-off-by jbaudoux
  • Loading branch information
OCA-git-bot committed Jan 8, 2025
2 parents c9ec474 + f765e96 commit 5442121
Show file tree
Hide file tree
Showing 14 changed files with 792 additions and 0 deletions.
6 changes: 6 additions & 0 deletions setup/stock_release_channel_plan_shipment_lead_time/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import setuptools

setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)
88 changes: 88 additions & 0 deletions stock_release_channel_plan_shipment_lead_time/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
=============================================
Stock release channel plan shipment lead time
=============================================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:a49d1682d1573486a083ed80a3ddf3cc1beddac90c39c98087fa59f6b457fd68
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |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%2Fwms-lightgray.png?logo=github
:target: https://github.com/OCA/wms/tree/16.0/stock_release_channel_plan_shipment_lead_time
:alt: OCA/wms
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/wms-16-0/wms-16-0-stock_release_channel_plan_shipment_lead_time
: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/wms&target_branch=16.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

When the release channel has a delivery lead time, visualize the preparation days based
on the delivery days and the lead time. When creating your preparation plan, you can
see which channel have to be prepared on which day.

**Table of contents**

.. contents::
:local:

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/wms/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 <https://github.com/OCA/wms/issues/new?body=module:%20stock_release_channel_plan_shipment_lead_time%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Credits
=======

Authors
~~~~~~~

* Camptocamp
* BCIM

Contributors
~~~~~~~~~~~~

* Jacques-Etienne Baudoux <[email protected]>
* Akim Juillerat <[email protected]>

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-jbaudoux| image:: https://github.com/jbaudoux.png?size=40px
:target: https://github.com/jbaudoux
:alt: jbaudoux

Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-jbaudoux|

This module is part of the `OCA/wms <https://github.com/OCA/wms/tree/16.0/stock_release_channel_plan_shipment_lead_time>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
1 change: 1 addition & 0 deletions stock_release_channel_plan_shipment_lead_time/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
21 changes: 21 additions & 0 deletions stock_release_channel_plan_shipment_lead_time/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Copyright 2024 Camptocamp SA
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl)
{
"name": "Stock release channel plan shipment lead time",
"summary": "Stock release channel plan shipment lead time",
"version": "16.0.1.0.0",
"development_status": "Beta",
"category": "Uncategorized",
"website": "https://github.com/OCA/wms",
"author": "Camptocamp, BCIM, Odoo Community Association (OCA)",
"maintainers": ["jbaudoux"],
"license": "AGPL-3",
"depends": [
"stock_release_channel_plan",
"stock_release_channel_shipment_lead_time",
],
"data": [
"views/release_channel.xml",
],
"auto_install": True,
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import res_partner
from . import stock_release_channel
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Copyright 2024 Camptocamp SA
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl)

from odoo import api, models


class ResPartner(models.Model):
_inherit = "res.partner"

@api.depends("stock_release_channel_ids.preparation_weekday_ids")
def _compute_stock_release_channel_delivery_weekday_ids(self):
# OVERRIDE to use delivery_weekday_ids instead of preparation_weekday_ids
for partner in self:
partner.stock_release_channel_delivery_weekday_ids = (
partner.stock_release_channel_ids.delivery_weekday_ids
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Copyright 2024 Camptocamp SA
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl)

from odoo import api, fields, models


class StockReleaseChannel(models.Model):
_inherit = "stock.release.channel"

delivery_weekday_ids = fields.Many2many(
"time.weekday",
"release_channel_delivery_weekday_rel",
"channel_id",
"weekday_id",
string="Delivery weekdays",
)
preparation_weekday_ids = fields.Many2many(
"time.weekday",
compute="_compute_preparation_weekday_ids",
readonly=True,
store=True,
)

@api.depends("delivery_weekday_ids", "shipment_lead_time")
def _compute_preparation_weekday_ids(self):
"""Preparation weekdays are delivery weekdays - lead time"""
for channel in self:
weekday_names = []
delivery_weekdays = channel.delivery_weekday_ids
for wd in delivery_weekdays:
if channel.warehouse_id.calendar_id:
# To consider days off in the calendar, we look for the next date
# from today on whose weekday matches with current delivery weekday.
# We then deduce the lead time using the calendar to find a weekday
# that is open.
# As this serves for helping in configuring the static preparation
# plan, we do not consider here the leaves.
date_from = wd._get_next_weekday_date()
date_from_minus_lead = channel.warehouse_id.calendar_id.plan_days(
-channel.shipment_lead_time,
fields.Datetime.to_datetime(date_from),
)
weekday_names.append(str(date_from_minus_lead.weekday()))
else:
# If we don't have a calendar, deduce lead time and look
# for corresponding weekday
wd_minus_lead = int(wd.name) - channel.shipment_lead_time
if wd_minus_lead < 0:
while not 0 <= wd_minus_lead < 7:
wd_minus_lead += 7
weekday_names.append(str(wd_minus_lead))
channel.preparation_weekday_ids = self.env["time.weekday"].search(
[("name", "in", weekday_names)]
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
* Jacques-Etienne Baudoux <[email protected]>
* Akim Juillerat <[email protected]>
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
When the release channel has a delivery lead time, visualize the preparation days based
on the delivery days and the lead time. When creating your preparation plan, you can
see which channel have to be prepared on which day.
Loading

0 comments on commit 5442121

Please sign in to comment.