Skip to content

Commit

Permalink
[ADD] stock_release_channel_shipment_lead_time
Browse files Browse the repository at this point in the history
  • Loading branch information
anothingguy authored and simahawk committed Oct 6, 2023
1 parent e6396f2 commit 851a9f7
Show file tree
Hide file tree
Showing 20 changed files with 864 additions and 0 deletions.
6 changes: 6 additions & 0 deletions setup/stock_release_channel_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,
)
96 changes: 96 additions & 0 deletions stock_release_channel_shipment_lead_time/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
==================================
Release channel shipment lead time
==================================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:87e7e2feb009b92bbd09928c5595063318fc6e124884cb346f6b57e459cfb917
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |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_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_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/webui/builds.html?repo=OCA/wms&target_branch=16.0
:alt: Try me on Runboat

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

This module allows to set delivery lead time for release channel.
When setting on shipment lead time on release channel, the shipment date is computed automatically base on
lead time days or warehouse calendar. There are 2 main enhanced features with this module:
- Filter deliveries base on shipment date defined on a channel
- Set delivery date for shipment advice if picking is linked to a channel

**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_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
~~~~~~~~~~~~

* `Trobz <https://trobz.com>`_:

* Hoang Diep <hoang@trobz.com>

Other credits
~~~~~~~~~~~~~

The development of this module has been financially supported by Camptocamp

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_shipment_lead_time>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
2 changes: 2 additions & 0 deletions stock_release_channel_shipment_lead_time/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import models
from . import wizards
25 changes: 25 additions & 0 deletions stock_release_channel_shipment_lead_time/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Copyright 2023 Camptocamp
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)

{
"name": "Release channel shipment lead time",
"summary": "Release channel with shipment lead time",
"version": "16.0.1.0.0",
"development_status": "Beta",
"license": "AGPL-3",
"author": "Camptocamp, BCIM, Odoo Community Association (OCA)",
"maintainers": ["jbaudoux"],
"website": "https://github.com/OCA/wms",
"depends": [
"web",
"stock_release_channel", # OCA/wms
"stock_release_channel_process_end_time", # OCA/wms
"stock_warehouse_calendar", # OCA/stock-logistics-warehouse
"shipment_advice_planner", # OCA/stock-logistics-transport
],
"data": [
"views/shipment_advice_views.xml",
"views/stock_release_channel_views.xml",
],
"installable": True,
}
3 changes: 3 additions & 0 deletions stock_release_channel_shipment_lead_time/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from . import stock_release_channel
from . import stock_picking
from . import shipment_advice
18 changes: 18 additions & 0 deletions stock_release_channel_shipment_lead_time/models/shipment_advice.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Copyright 2023 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl)

from odoo import fields, models


class ShipmentAdvice(models.Model):
_inherit = "shipment.advice"

delivery_date = fields.Date(
states={
"draft": [("readonly", False)],
"confirmed": [("readonly", False)],
"in_progress": [("readonly", False)],
},
readonly=True,
help=("maxium shipment date on the channel of related pickings"),
)
32 changes: 32 additions & 0 deletions stock_release_channel_shipment_lead_time/models/stock_picking.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Copyright 2023 Camptocamp
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from odoo import fields, models


class StockPicking(models.Model):

_inherit = "stock.picking"

def _get_release_channel_possible_candidate_domain(self):
"""
override to exclude deliveries (OUT pickings) where
the date_deadline is after the shipment date.
"""
self.ensure_one()
domain = super()._get_release_channel_possible_candidate_domain()

# date_deadline is datetime UTC => convert to timezone user to compare
# with shipment_date is date
if self.date_deadline:
date_deadline = fields.Datetime.context_timestamp(
self, self.date_deadline
).date()

domain.extend(
[
"|",
("shipment_date", "=", False),
("shipment_date", ">=", date_deadline),
]
)
return domain
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Copyright 2023 Camptocamp
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)
from datetime import timedelta

from odoo import api, fields, models


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

shipment_lead_time = fields.Integer(help="Shipment Lead Time (days)")
shipment_date = fields.Date(
compute="_compute_shipment_date",
store=True,
help=(
"if no warehouse or no calendar on the warehouse:"
"process end date + shipment lead time."
"Otherwise, it's counted by calendar included leaves:"
"number of days = lead time + 1"
),
)

@api.depends(
"process_end_date",
"shipment_lead_time",
"warehouse_id",
"warehouse_id.calendar_id",
)
def _compute_shipment_date(self):
"""
if no warehouse or no calendar on the warehouse:
process end date + lead time
else: use calendar.plan_days(days, date_from, compute_leaves=True)
where days is amount of required open days (= lead time + 1)
"""
for channel in self:
shipment_date = False
if channel.process_end_date:
shipment_date = channel.process_end_date + timedelta(
days=channel.shipment_lead_time
)
if channel.warehouse_id.calendar_id:
days = channel.shipment_lead_time + 1
shipment_date = channel.warehouse_id.calendar_id.plan_days(
days, channel.process_end_date, compute_leaves=True
)
channel.shipment_date = shipment_date
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
* `Trobz <https://trobz.com>`_:

* Hoang Diep <hoang@trobz.com>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The development of this module has been financially supported by Camptocamp
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
This module allows to set delivery lead time for release channel.
When setting on shipment lead time on release channel, the shipment date is computed automatically base on
lead time days or warehouse calendar. There are 2 main enhanced features with this module:
- Filter deliveries base on shipment date defined on a channel
- Set delivery date for shipment advice if picking is linked to a channel
Loading

0 comments on commit 851a9f7

Please sign in to comment.