Skip to content

Commit 5442121

Browse files
committed
Merge PR #827 into 16.0
Signed-off-by jbaudoux
2 parents c9ec474 + f765e96 commit 5442121

File tree

14 files changed

+792
-0
lines changed

14 files changed

+792
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../../stock_release_channel_plan_shipment_lead_time
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import setuptools
2+
3+
setuptools.setup(
4+
setup_requires=['setuptools-odoo'],
5+
odoo_addon=True,
6+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
=============================================
2+
Stock release channel plan shipment lead time
3+
=============================================
4+
5+
..
6+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
7+
!! This file is generated by oca-gen-addon-readme !!
8+
!! changes will be overwritten. !!
9+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
10+
!! source digest: sha256:a49d1682d1573486a083ed80a3ddf3cc1beddac90c39c98087fa59f6b457fd68
11+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
12+
13+
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
14+
:target: https://odoo-community.org/page/development-status
15+
:alt: Beta
16+
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
17+
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
18+
:alt: License: AGPL-3
19+
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fwms-lightgray.png?logo=github
20+
:target: https://github.com/OCA/wms/tree/16.0/stock_release_channel_plan_shipment_lead_time
21+
:alt: OCA/wms
22+
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
23+
:target: https://translation.odoo-community.org/projects/wms-16-0/wms-16-0-stock_release_channel_plan_shipment_lead_time
24+
:alt: Translate me on Weblate
25+
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
26+
:target: https://runboat.odoo-community.org/builds?repo=OCA/wms&target_branch=16.0
27+
:alt: Try me on Runboat
28+
29+
|badge1| |badge2| |badge3| |badge4| |badge5|
30+
31+
When the release channel has a delivery lead time, visualize the preparation days based
32+
on the delivery days and the lead time. When creating your preparation plan, you can
33+
see which channel have to be prepared on which day.
34+
35+
**Table of contents**
36+
37+
.. contents::
38+
:local:
39+
40+
Bug Tracker
41+
===========
42+
43+
Bugs are tracked on `GitHub Issues <https://github.com/OCA/wms/issues>`_.
44+
In case of trouble, please check there if your issue has already been reported.
45+
If you spotted it first, help us to smash it by providing a detailed and welcomed
46+
`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**>`_.
47+
48+
Do not contact contributors directly about support or help with technical issues.
49+
50+
Credits
51+
=======
52+
53+
Authors
54+
~~~~~~~
55+
56+
* Camptocamp
57+
* BCIM
58+
59+
Contributors
60+
~~~~~~~~~~~~
61+
62+
* Jacques-Etienne Baudoux <je@bcim.be>
63+
* Akim Juillerat <akim.juillerat@camptocamp.com>
64+
65+
Maintainers
66+
~~~~~~~~~~~
67+
68+
This module is maintained by the OCA.
69+
70+
.. image:: https://odoo-community.org/logo.png
71+
:alt: Odoo Community Association
72+
:target: https://odoo-community.org
73+
74+
OCA, or the Odoo Community Association, is a nonprofit organization whose
75+
mission is to support the collaborative development of Odoo features and
76+
promote its widespread use.
77+
78+
.. |maintainer-jbaudoux| image:: https://github.com/jbaudoux.png?size=40px
79+
:target: https://github.com/jbaudoux
80+
:alt: jbaudoux
81+
82+
Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:
83+
84+
|maintainer-jbaudoux|
85+
86+
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.
87+
88+
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from . import models
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Copyright 2024 Camptocamp SA
2+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl)
3+
{
4+
"name": "Stock release channel plan shipment lead time",
5+
"summary": "Stock release channel plan shipment lead time",
6+
"version": "16.0.1.0.0",
7+
"development_status": "Beta",
8+
"category": "Uncategorized",
9+
"website": "https://github.com/OCA/wms",
10+
"author": "Camptocamp, BCIM, Odoo Community Association (OCA)",
11+
"maintainers": ["jbaudoux"],
12+
"license": "AGPL-3",
13+
"depends": [
14+
"stock_release_channel_plan",
15+
"stock_release_channel_shipment_lead_time",
16+
],
17+
"data": [
18+
"views/release_channel.xml",
19+
],
20+
"auto_install": True,
21+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
from . import res_partner
2+
from . import stock_release_channel
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Copyright 2024 Camptocamp SA
2+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl)
3+
4+
from odoo import api, models
5+
6+
7+
class ResPartner(models.Model):
8+
_inherit = "res.partner"
9+
10+
@api.depends("stock_release_channel_ids.preparation_weekday_ids")
11+
def _compute_stock_release_channel_delivery_weekday_ids(self):
12+
# OVERRIDE to use delivery_weekday_ids instead of preparation_weekday_ids
13+
for partner in self:
14+
partner.stock_release_channel_delivery_weekday_ids = (
15+
partner.stock_release_channel_ids.delivery_weekday_ids
16+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# Copyright 2024 Camptocamp SA
2+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl)
3+
4+
from odoo import api, fields, models
5+
6+
7+
class StockReleaseChannel(models.Model):
8+
_inherit = "stock.release.channel"
9+
10+
delivery_weekday_ids = fields.Many2many(
11+
"time.weekday",
12+
"release_channel_delivery_weekday_rel",
13+
"channel_id",
14+
"weekday_id",
15+
string="Delivery weekdays",
16+
)
17+
preparation_weekday_ids = fields.Many2many(
18+
"time.weekday",
19+
compute="_compute_preparation_weekday_ids",
20+
readonly=True,
21+
store=True,
22+
)
23+
24+
@api.depends("delivery_weekday_ids", "shipment_lead_time")
25+
def _compute_preparation_weekday_ids(self):
26+
"""Preparation weekdays are delivery weekdays - lead time"""
27+
for channel in self:
28+
weekday_names = []
29+
delivery_weekdays = channel.delivery_weekday_ids
30+
for wd in delivery_weekdays:
31+
if channel.warehouse_id.calendar_id:
32+
# To consider days off in the calendar, we look for the next date
33+
# from today on whose weekday matches with current delivery weekday.
34+
# We then deduce the lead time using the calendar to find a weekday
35+
# that is open.
36+
# As this serves for helping in configuring the static preparation
37+
# plan, we do not consider here the leaves.
38+
date_from = wd._get_next_weekday_date()
39+
date_from_minus_lead = channel.warehouse_id.calendar_id.plan_days(
40+
-channel.shipment_lead_time,
41+
fields.Datetime.to_datetime(date_from),
42+
)
43+
weekday_names.append(str(date_from_minus_lead.weekday()))
44+
else:
45+
# If we don't have a calendar, deduce lead time and look
46+
# for corresponding weekday
47+
wd_minus_lead = int(wd.name) - channel.shipment_lead_time
48+
if wd_minus_lead < 0:
49+
while not 0 <= wd_minus_lead < 7:
50+
wd_minus_lead += 7
51+
weekday_names.append(str(wd_minus_lead))
52+
channel.preparation_weekday_ids = self.env["time.weekday"].search(
53+
[("name", "in", weekday_names)]
54+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
* Jacques-Etienne Baudoux <je@bcim.be>
2+
* Akim Juillerat <akim.juillerat@camptocamp.com>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
When the release channel has a delivery lead time, visualize the preparation days based
2+
on the delivery days and the lead time. When creating your preparation plan, you can
3+
see which channel have to be prepared on which day.

0 commit comments

Comments
 (0)