Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[17.0][MIG] stock_warehouse_calendar: Migration to 17.0 #1933

Merged
merged 44 commits into from
Mar 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
889ad73
11.0 - add stock_warehouse_calendar
JordiBForgeFlow Jun 28, 2018
106ff5e
[UPD] Update stock_warehouse_calendar.pot
oca-travis Jul 4, 2018
f93225f
[FIX] remove empty file that breaks readme generator
sbidoul Jul 6, 2018
2b01b74
[UPD] README.rst
OCA-git-bot Jul 10, 2018
5dc46a3
[MIG] stock_warehouse_calendar: Migration to 12.0
MiquelRForgeFlow Mar 20, 2019
5369a10
[UPD] README.rst
OCA-git-bot Apr 23, 2019
ea791ab
[UPD] Update stock_warehouse_calendar.pot
oca-travis Apr 23, 2019
ff34adc
[UPD] README.rst
OCA-git-bot Jul 29, 2019
ad5fe92
[12.0][REW] stock_warehouse_calendar: add plan days helper method
LoisRForgeFlow Jul 31, 2019
3459811
[UPD] README.rst
OCA-git-bot Aug 5, 2019
f0c693d
stock_warehouse_calendar 12.0.1.0.1
OCA-git-bot Aug 5, 2019
a28d2af
Added translation using Weblate (Chinese (Simplified))
liweijie0812 Oct 16, 2019
9ff96a6
Translated using Weblate (Chinese (Simplified))
liweijie0812 Oct 16, 2019
96e043f
[IMP] stock_warehouse_calendar: black, isort
LoisRForgeFlow Dec 17, 2019
ce9efce
[13.0][MIG] stock_warehouse_calendar
LoisRForgeFlow Dec 17, 2019
ceecb84
[UPD] Update stock_warehouse_calendar.pot
oca-travis Dec 17, 2019
c15a529
[UPD] README.rst
OCA-git-bot Dec 17, 2019
ce5d836
pre-commit update
OCA-git-bot Mar 14, 2020
e0b23f7
[IMP] stock_warehouse_calendar: robustness
LoisRForgeFlow Jun 23, 2020
05e9752
stock_warehouse_calendar 13.0.1.0.1
OCA-git-bot Jun 24, 2020
067ad1c
[IMP] stock_warehouse_calendar: black, isort, prettier
MateuGForgeFlow Jan 4, 2021
20d38c3
[MIG] stock_warehouse_calendar: Migration to 14.0
DavidBForgeFlow Feb 12, 2021
c1c8831
[UPD] Update stock_warehouse_calendar.pot
oca-travis Feb 15, 2021
8c142ef
[UPD] README.rst
OCA-git-bot Feb 15, 2021
a66b3a5
Added translation using Weblate (Italian)
francesco-ooops Oct 5, 2021
cc34fd4
Translated using Weblate (Italian)
francesco-ooops Oct 5, 2021
2bc86e5
[MIG] stock_warehouse_calendar: Migration to 15.0
JoanMForgeFlow Oct 26, 2021
ccb67e0
[UPD] Update stock_warehouse_calendar.pot
Oct 27, 2021
1f5eb08
[UPD] README.rst
OCA-git-bot Oct 27, 2021
d1e2077
[IMP] stock_warehouse_calendar: upgrade development status
AaronHForgeFlow Oct 28, 2021
a25e280
Added translation using Weblate (Catalan)
jabelchi Aug 17, 2022
24581a9
Translated using Weblate (Catalan)
jabelchi Aug 17, 2022
b6d8178
[MIG] stock_warehouse_calendar: Migration to 16.0
TDu Oct 10, 2022
e281227
stock_warehouse_calendar: improve tests
TDu Oct 10, 2022
fb717c6
[UPD] Update stock_warehouse_calendar.pot
Nov 4, 2022
65a08f7
[UPD] README.rst
OCA-git-bot Nov 4, 2022
5807f81
Update translation files
weblate Nov 4, 2022
7c49611
Added translation using Weblate (Spanish)
Ivorra78 Jul 28, 2023
1aa37a2
Translated using Weblate (Spanish)
Ivorra78 Jul 28, 2023
6b6ed39
[UPD] README.rst
OCA-git-bot Sep 3, 2023
cb51930
Translated using Weblate (Italian)
mymage Nov 21, 2023
627d93a
[IMP] stock_warehouse_calendar: pre-commit auto fixes
Jan 25, 2024
e9e05a4
[MIG] stock_warehouse_calendar: Migration to 17.0
Jan 25, 2024
7edd2c2
[FIX] stock_warehouse_calendar: stock_rule
Feb 6, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added pandoc-3.1.11.1-1-amd64.deb
Binary file not shown.
117 changes: 117 additions & 0 deletions stock_warehouse_calendar/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
========================
Stock Warehouse Calendar
========================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:edc36f1398bb8291c606982b918585daa317c0c4eb42c7847085500fd33de00e
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |badge1| image:: https://img.shields.io/badge/maturity-Production%2FStable-green.png
:target: https://odoo-community.org/page/development-status
:alt: Production/Stable
.. |badge2| image:: https://img.shields.io/badge/licence-LGPL--3-blue.png
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
:alt: License: LGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fstock--logistics--warehouse-lightgray.png?logo=github
:target: https://github.com/OCA/stock-logistics-warehouse/tree/17.0/stock_warehouse_calendar
:alt: OCA/stock-logistics-warehouse
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/stock-logistics-warehouse-17-0/stock-logistics-warehouse-17-0-stock_warehouse_calendar
: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/stock-logistics-warehouse&target_branch=17.0
:alt: Try me on Runboat

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

This module adds a Calendar to the Warehouse. This calendar can then
used as the basis of the proper computation of start/end dates based on
lead times in this and other modules.

In this module, the calendar considered in the computation of start date
of stock moves and pickings created from procurements, where the lead
time is used.

**Table of contents**

.. contents::
:local:

Configuration
=============

- Go to *Settings* and activate the developer mode.
- Go to *Settings > Technical > Resource > Working Time* and define
your resource calendar.
- Go to *Inventory > Configuration > Warehouse Management > Warehouses*
and assign the Resource Calendar.
- Go to *Inventory > Configuration > Settings* and in *Warehouse* mark
'Multi-Step Routes option'.
- Go to *Inventory > Configuration > Warehouse Management > Routes* and
set up the proper delays in the stock rules where 'action' is 'Move
From Another Location'.

Usage
=====

When a picking is created out of a procurement evaluation (from an
orderpoint, MTO,...) the calendar is considered in the computation of
the expected date of the picking and moves. For example, if it takes 1
day to execute a stock transfer from another warehouse and it is Monday,
the picking to resupply will be created with expected start date on the
previous Friday, if the warehouse operates under a Mo-Fri working
calendar.

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

Bugs are tracked on `GitHub Issues <https://github.com/OCA/stock-logistics-warehouse/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/stock-logistics-warehouse/issues/new?body=module:%20stock_warehouse_calendar%0Aversion:%2017.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
-------

* ForgeFlow

Contributors
------------

- Jordi Ballester <jordi.ballester@forgeflow.com>
- Lois Rilo <lois.rilo@forgeflow.com>
- Joan Mateu <joan.mateu@forgeflow.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.

.. |maintainer-JordiBForgeFlow| image:: https://github.com/JordiBForgeFlow.png?size=40px
:target: https://github.com/JordiBForgeFlow
:alt: JordiBForgeFlow

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

|maintainer-JordiBForgeFlow|

This module is part of the `OCA/stock-logistics-warehouse <https://github.com/OCA/stock-logistics-warehouse/tree/17.0/stock_warehouse_calendar>`_ 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_warehouse_calendar/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
from . import models
17 changes: 17 additions & 0 deletions stock_warehouse_calendar/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Copyright 2021 ForgeFlow S.L. (https://www.forgeflow.com)
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).

{
"name": "Stock Warehouse Calendar",
"summary": "Adds a calendar to the Warehouse",
"version": "17.0.1.0.0",
"license": "LGPL-3",
"website": "https://github.com/OCA/stock-logistics-warehouse",
"author": "ForgeFlow, " "Odoo Community Association (OCA)",
"category": "Warehouse Management",
"depends": ["stock", "resource"],
"data": ["views/stock_warehouse_views.xml"],
"installable": True,
"development_status": "Production/Stable",
"maintainers": ["JordiBForgeFlow"],
}
32 changes: 32 additions & 0 deletions stock_warehouse_calendar/i18n/ca.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * stock_warehouse_calendar
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 15.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2022-08-17 12:07+0000\n"
"Last-Translator: jabelchi <jabelchi@gmail.com>\n"
"Language-Team: none\n"
"Language: ca\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Generator: Weblate 4.3.2\n"

#. module: stock_warehouse_calendar
#: model:ir.model,name:stock_warehouse_calendar.model_stock_rule
msgid "Stock Rule"
msgstr "Regla d'estoc"

#. module: stock_warehouse_calendar
#: model:ir.model,name:stock_warehouse_calendar.model_stock_warehouse
msgid "Warehouse"
msgstr "Magatzem"

#. module: stock_warehouse_calendar
#: model:ir.model.fields,field_description:stock_warehouse_calendar.field_stock_warehouse__calendar_id
msgid "Working Hours"
msgstr "Hores de treball"
32 changes: 32 additions & 0 deletions stock_warehouse_calendar/i18n/es.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * stock_warehouse_calendar
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2023-07-28 21:10+0000\n"
"Last-Translator: Ivorra78 <informatica@totmaterial.es>\n"
"Language-Team: none\n"
"Language: es\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Generator: Weblate 4.17\n"

#. module: stock_warehouse_calendar
#: model:ir.model,name:stock_warehouse_calendar.model_stock_rule
msgid "Stock Rule"
msgstr "Regla de existencias"

#. module: stock_warehouse_calendar
#: model:ir.model,name:stock_warehouse_calendar.model_stock_warehouse
msgid "Warehouse"
msgstr "Almacén"

#. module: stock_warehouse_calendar
#: model:ir.model.fields,field_description:stock_warehouse_calendar.field_stock_warehouse__calendar_id
msgid "Working Hours"
msgstr "Horario de trabajo"
35 changes: 35 additions & 0 deletions stock_warehouse_calendar/i18n/it.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * stock_warehouse_calendar
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 14.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2023-11-21 13:33+0000\n"
"Last-Translator: mymage <stefano.consolaro@mymage.it>\n"
"Language-Team: none\n"
"Language: it\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Generator: Weblate 4.17\n"

#. module: stock_warehouse_calendar
#: model:ir.model,name:stock_warehouse_calendar.model_stock_rule
msgid "Stock Rule"
msgstr "Regola di giacenza"

#. module: stock_warehouse_calendar
#: model:ir.model,name:stock_warehouse_calendar.model_stock_warehouse
msgid "Warehouse"
msgstr "Magazzino"

#. module: stock_warehouse_calendar
#: model:ir.model.fields,field_description:stock_warehouse_calendar.field_stock_warehouse__calendar_id
msgid "Working Hours"
msgstr "Orario lavorativo"

#~ msgid "Last Modified on"
#~ msgstr "Ultima modifica il"
29 changes: 29 additions & 0 deletions stock_warehouse_calendar/i18n/stock_warehouse_calendar.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * stock_warehouse_calendar
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

#. module: stock_warehouse_calendar
#: model:ir.model,name:stock_warehouse_calendar.model_stock_rule
msgid "Stock Rule"
msgstr ""

#. module: stock_warehouse_calendar
#: model:ir.model,name:stock_warehouse_calendar.model_stock_warehouse
msgid "Warehouse"
msgstr ""

#. module: stock_warehouse_calendar
#: model:ir.model.fields,field_description:stock_warehouse_calendar.field_stock_warehouse__calendar_id
msgid "Working Hours"
msgstr ""
32 changes: 32 additions & 0 deletions stock_warehouse_calendar/i18n/zh_CN.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * stock_warehouse_calendar
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 12.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2019-10-16 15:58+0000\n"
"Last-Translator: 黎伟杰 <674416404@qq.com>\n"
"Language-Team: none\n"
"Language: zh_CN\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=1; plural=0;\n"
"X-Generator: Weblate 3.8\n"

#. module: stock_warehouse_calendar
#: model:ir.model,name:stock_warehouse_calendar.model_stock_rule
msgid "Stock Rule"
msgstr "库存规则"

#. module: stock_warehouse_calendar
#: model:ir.model,name:stock_warehouse_calendar.model_stock_warehouse
msgid "Warehouse"
msgstr "仓库"

#. module: stock_warehouse_calendar
#: model:ir.model.fields,field_description:stock_warehouse_calendar.field_stock_warehouse__calendar_id
msgid "Working Hours"
msgstr "工作时间"
3 changes: 3 additions & 0 deletions stock_warehouse_calendar/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
from . import stock_warehouse
from . import stock_rule
36 changes: 36 additions & 0 deletions stock_warehouse_calendar/models/stock_rule.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Copyright 2018-19 ForgeFlow S.L. (https://www.forgeflow.com)
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).


from odoo import models


class StockRule(models.Model):
_inherit = "stock.rule"

def _get_stock_move_values(
self,
product_id,
product_qty,
product_uom,
location_id,
name,
origin,
company_id,
values,
):
res = super()._get_stock_move_values(
product_id,
product_qty,
product_uom,
location_id,
name,
origin,
company_id,
values,
)
warehouse = self.propagate_warehouse_id or self.warehouse_id
if warehouse.calendar_id and self.delay:
date = warehouse.wh_plan_days(values["date_planned"], -1 * self.delay)
res["date"] = date
return res
43 changes: 43 additions & 0 deletions stock_warehouse_calendar/models/stock_warehouse.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Copyright 2018-19 ForgeFlow S.L. (https://www.forgeflow.com)
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).

from datetime import datetime, timedelta

from odoo import fields, models


class StockWarehouse(models.Model):
_inherit = "stock.warehouse"

calendar_id = fields.Many2one(
comodel_name="resource.calendar", string="Working Hours"
)

def wh_plan_days(self, date_from, delta):
"""Helper method to schedule warehouse operations based on its
working days (if set).

:param datetime date_from: reference date.
:param integer delta: offset to apply.
:return: datetime: resulting date.
"""
self.ensure_one()
if isinstance(delta, float):
delta = round(delta)

Check warning on line 26 in stock_warehouse_calendar/models/stock_warehouse.py

View check run for this annotation

Codecov / codecov/patch

stock_warehouse_calendar/models/stock_warehouse.py#L26

Added line #L26 was not covered by tests
if not isinstance(date_from, datetime):
date_from = fields.Datetime.to_datetime(date_from)
if delta == 0:
return date_from

Check warning on line 30 in stock_warehouse_calendar/models/stock_warehouse.py

View check run for this annotation

Codecov / codecov/patch

stock_warehouse_calendar/models/stock_warehouse.py#L30

Added line #L30 was not covered by tests

if self.calendar_id:
if delta < 0:
# We force the date planned to be at the beginning of the day.
# So no work intervals are found in the reference date.
dt_planned = date_from.replace(hour=0)
else:
# We force the date planned at the end of the day.
dt_planned = date_from.replace(hour=23)
date_result = self.calendar_id.plan_days(delta, dt_planned)
else:
date_result = date_from + timedelta(days=delta)
return date_result
3 changes: 3 additions & 0 deletions stock_warehouse_calendar/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["whool"]
build-backend = "whool.buildapi"
Loading
Loading