Skip to content

Commit

Permalink
sale_partner_cutoff_delivery_window: cut-off after delivery window
Browse files Browse the repository at this point in the history
When a customer has a delivery time window, we want to apply the cut-off
time on the scheduded date.

Whenever we have a customer with weekly delivery, the scheduled datetime
of the delivery must be set at the cut-off time for this order:

* e.g. I set a customer to be shipped on Tuesday and Thursday between 13:55-14:30,
* I place a SO on the 29th of November 2020, my scheduled datetime on my
  delivery must be 1st december at 09:00
* 1st december because it is the next Tuesday from the order creation
* 09:00 because my cut-off time for WH is set at 09:00 and the customer
  doesn't have any specific cut-off time
  • Loading branch information
guewen authored and simahawk committed Dec 16, 2020
1 parent f85191d commit 4fa737e
Show file tree
Hide file tree
Showing 8 changed files with 647 additions and 16 deletions.
80 changes: 80 additions & 0 deletions sale_partner_cutoff_delivery_window/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
===================================
Sale Partner Cutoff Delivery Window
===================================

.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Alpha-red.png
:target: https://odoo-community.org/page/development-status
:alt: Alpha
.. |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%2Fsale--workflow-lightgray.png?logo=github
:target: https://github.com/OCA/sale-workflow/tree/13.0/sale_partner_cutoff_delivery_window
:alt: OCA/sale-workflow
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/sale-workflow-13-0/sale-workflow-13-0-sale_partner_cutoff_delivery_window
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/167/13.0
:alt: Try me on Runbot

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

Glue module between `sale_cutoff_time_delivery` and `sale_partner_delivery_window`.
Makes sure date planned considers the cutoff time window.

.. IMPORTANT::
This is an alpha version, the data model and design can change at any time without warning.
Only for development or testing purpose, do not use in production.
`More details on development status <https://odoo-community.org/page/development-status>`_

**Table of contents**

.. contents::
:local:

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

Bugs are tracked on `GitHub Issues <https://github.com/OCA/sale-workflow/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed
`feedback <https://github.com/OCA/sale-workflow/issues/new?body=module:%20sale_partner_cutoff_delivery_window%0Aversion:%2013.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

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

* Akim Juillerat <akim.juillerat@camptocamp.com>
* Guewen Baconnier <guewen.baconnier@camptocamp.com>

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.

This module is part of the `OCA/sale-workflow <https://github.com/OCA/sale-workflow/tree/13.0/sale_partner_cutoff_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 sale_partner_cutoff_delivery_window/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# Copyright 2020 Camptocamp SA
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl)
from . import models
1 change: 1 addition & 0 deletions sale_partner_cutoff_delivery_window/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import sale_order_line
25 changes: 25 additions & 0 deletions sale_partner_cutoff_delivery_window/models/sale_order_line.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Copyright 2020 Camptocamp SA
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl)
from odoo import models


class SaleOrderLine(models.Model):

_inherit = "sale.order.line"

def _prepare_procurement_values_time_windows(self, date_planned):
new_date_planned = super()._prepare_procurement_values_time_windows(
date_planned
)
if new_date_planned:
# if we had a new datetime proposed by a delivery time window,
# apply the warehouse/partner cutoff time
cutoff_datetime = self._prepare_procurement_values_cutoff_time(
new_date_planned,
# the correct day has already been computed, only change
# the cut-off time
keep_same_day=True,
)
if cutoff_datetime:
return cutoff_datetime
return new_date_planned
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
* Akim Juillerat <akim.juillerat@camptocamp.com>
* Guewen Baconnier <guewen.baconnier@camptocamp.com>
5 changes: 2 additions & 3 deletions sale_partner_cutoff_delivery_window/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
This module adds some unittests to ensure Method Resolution Order of
`sale.order.line._prepare_procurement_values` for modules
`sale_cutoff_time_delivery` and `sale_partner_delivery_window` is correct.
Glue module between `sale_cutoff_time_delivery` and `sale_partner_delivery_window`.
Makes sure date planned considers the cutoff time window.
Loading

0 comments on commit 4fa737e

Please sign in to comment.