Skip to content

Commit

Permalink
[ADD] stock_release_channel_partner_delivery_window
Browse files Browse the repository at this point in the history
  • Loading branch information
nguyenminhchien committed Nov 21, 2023
1 parent d608609 commit 93ab520
Show file tree
Hide file tree
Showing 17 changed files with 726 additions and 0 deletions.
6 changes: 6 additions & 0 deletions setup/stock_release_channel_partner_delivery_window/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,
)
91 changes: 91 additions & 0 deletions stock_release_channel_partner_delivery_window/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
=============================================
Stock Release Channel Partner Delivery Window
=============================================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:19aeedd318a1b32f8829dc2bad0e0c7a27141d473a05db3aa90b3a6694b46390
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |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_partner_delivery_window
: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_partner_delivery_window
: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|

This module excludes the channel when its shipment date is not in Partner delivery window

**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_partner_delivery_window%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
~~~~~~~~~~~~

* Nguyen Minh Chien <[email protected]>
* Jacques-Etienne Baudoux <[email protected]>

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_partner_delivery_window>`_ 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_partner_delivery_window/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
20 changes: 20 additions & 0 deletions stock_release_channel_partner_delivery_window/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

{
"name": "Stock Release Channel Partner Delivery Window",
"summary": """
Allows to define an end date (and time) on a release channel and
propagate it to the concerned pickings""",
"version": "16.0.1.0.0",
"license": "AGPL-3",
"maintainers": ["jbaudoux"],
"author": "Camptocamp, BCIM, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/wms",
"depends": [
"stock_partner_delivery_window",
"stock_release_channel_shipment_lead_time",
],
"data": [
"views/stock_release_channel_view.xml",
],
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import stock_picking
from . import stock_release_channel
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from odoo import models


class StockPicking(models.Model):

_inherit = "stock.picking"

def _find_release_channel_possible_candidate(self):
"""Filter channels: make sure shipment date is in Partner window
:return: release channels
"""
channels = super()._find_release_channel_possible_candidate()
channels = channels.filter_release_channel_partner_window(self, self.partner_id)
return channels
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from odoo import fields, models


class StockReleaseChannel(models.Model):

_inherit = "stock.release.channel"

respect_partner_delivery_time_windows = fields.Boolean(
string="Respect Partner Delivery time windows",
default=False,
help=(
"If the delivery has moves linked to SO lines linked to SO that has"
" a commitment_date, then we never respect the partner time window "
"(it is not an exclusion selection criteria anymore)"
),
)

def filter_release_channel_partner_window(self, picking, partner):
channels = self
if (
not partner.delivery_time_preference
or partner.delivery_time_preference == "anytime"
):
return channels

for channel in self:
if not channel.shipment_date:
continue
shipment_datetime = fields.Datetime.to_datetime(channel.shipment_date)
if channel.process_end_date:
shipment_datetime = shipment_datetime.replace(
hour=channel.process_end_date.hour,
minute=channel.process_end_date.minute,
)
if (
channel.respect_partner_delivery_time_windows
and not picking.sale_id.commitment_date
and not partner.is_in_delivery_window(shipment_datetime)
):
channels -= channel
return channels
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
* Nguyen Minh Chien <[email protected]>
* Jacques-Etienne Baudoux <[email protected]>
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 @@
This module excludes the channel when its shipment date is not in Partner delivery window
Empty file.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 93ab520

Please sign in to comment.