diff --git a/pandoc-3.1.11.1-1-amd64.deb b/pandoc-3.1.11.1-1-amd64.deb new file mode 100644 index 000000000000..1af3187f705d Binary files /dev/null and b/pandoc-3.1.11.1-1-amd64.deb differ diff --git a/stock_warehouse_calendar/README.rst b/stock_warehouse_calendar/README.rst new file mode 100644 index 000000000000..c445910fd90b --- /dev/null +++ b/stock_warehouse_calendar/README.rst @@ -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 `_. +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 `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +------- + +* ForgeFlow + +Contributors +------------ + +- Jordi Ballester +- Lois Rilo +- Joan Mateu + +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 `__: + +|maintainer-JordiBForgeFlow| + +This module is part of the `OCA/stock-logistics-warehouse `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/stock_warehouse_calendar/__init__.py b/stock_warehouse_calendar/__init__.py new file mode 100644 index 000000000000..133f68732d31 --- /dev/null +++ b/stock_warehouse_calendar/__init__.py @@ -0,0 +1,2 @@ +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). +from . import models diff --git a/stock_warehouse_calendar/__manifest__.py b/stock_warehouse_calendar/__manifest__.py new file mode 100644 index 000000000000..9921b1f8323b --- /dev/null +++ b/stock_warehouse_calendar/__manifest__.py @@ -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"], +} diff --git a/stock_warehouse_calendar/i18n/ca.po b/stock_warehouse_calendar/i18n/ca.po new file mode 100644 index 000000000000..d468b9d6e313 --- /dev/null +++ b/stock_warehouse_calendar/i18n/ca.po @@ -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 \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" diff --git a/stock_warehouse_calendar/i18n/es.po b/stock_warehouse_calendar/i18n/es.po new file mode 100644 index 000000000000..4e17ca6c9051 --- /dev/null +++ b/stock_warehouse_calendar/i18n/es.po @@ -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 \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" diff --git a/stock_warehouse_calendar/i18n/it.po b/stock_warehouse_calendar/i18n/it.po new file mode 100644 index 000000000000..3351a45bc015 --- /dev/null +++ b/stock_warehouse_calendar/i18n/it.po @@ -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 \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" diff --git a/stock_warehouse_calendar/i18n/stock_warehouse_calendar.pot b/stock_warehouse_calendar/i18n/stock_warehouse_calendar.pot new file mode 100644 index 000000000000..2972d6f9b0d3 --- /dev/null +++ b/stock_warehouse_calendar/i18n/stock_warehouse_calendar.pot @@ -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 "" diff --git a/stock_warehouse_calendar/i18n/zh_CN.po b/stock_warehouse_calendar/i18n/zh_CN.po new file mode 100644 index 000000000000..b9b991be2fd7 --- /dev/null +++ b/stock_warehouse_calendar/i18n/zh_CN.po @@ -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 "工作时间" diff --git a/stock_warehouse_calendar/models/__init__.py b/stock_warehouse_calendar/models/__init__.py new file mode 100644 index 000000000000..200eddbf2529 --- /dev/null +++ b/stock_warehouse_calendar/models/__init__.py @@ -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 diff --git a/stock_warehouse_calendar/models/stock_rule.py b/stock_warehouse_calendar/models/stock_rule.py new file mode 100644 index 000000000000..af6b66cc185a --- /dev/null +++ b/stock_warehouse_calendar/models/stock_rule.py @@ -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 diff --git a/stock_warehouse_calendar/models/stock_warehouse.py b/stock_warehouse_calendar/models/stock_warehouse.py new file mode 100644 index 000000000000..c7dc0082c559 --- /dev/null +++ b/stock_warehouse_calendar/models/stock_warehouse.py @@ -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) + if not isinstance(date_from, datetime): + date_from = fields.Datetime.to_datetime(date_from) + if delta == 0: + return date_from + + 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 diff --git a/stock_warehouse_calendar/pyproject.toml b/stock_warehouse_calendar/pyproject.toml new file mode 100644 index 000000000000..4231d0cccb3d --- /dev/null +++ b/stock_warehouse_calendar/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/stock_warehouse_calendar/readme/CONFIGURE.md b/stock_warehouse_calendar/readme/CONFIGURE.md new file mode 100644 index 000000000000..42d444ea87cd --- /dev/null +++ b/stock_warehouse_calendar/readme/CONFIGURE.md @@ -0,0 +1,10 @@ +- 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'. diff --git a/stock_warehouse_calendar/readme/CONTRIBUTORS.md b/stock_warehouse_calendar/readme/CONTRIBUTORS.md new file mode 100644 index 000000000000..3314bef0fed3 --- /dev/null +++ b/stock_warehouse_calendar/readme/CONTRIBUTORS.md @@ -0,0 +1,3 @@ +- Jordi Ballester \<\> +- Lois Rilo \<\> +- Joan Mateu \<\> diff --git a/stock_warehouse_calendar/readme/DESCRIPTION.md b/stock_warehouse_calendar/readme/DESCRIPTION.md new file mode 100644 index 000000000000..e61804fd7125 --- /dev/null +++ b/stock_warehouse_calendar/readme/DESCRIPTION.md @@ -0,0 +1,7 @@ +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. diff --git a/stock_warehouse_calendar/readme/USAGE.md b/stock_warehouse_calendar/readme/USAGE.md new file mode 100644 index 000000000000..28afd8c5cf6f --- /dev/null +++ b/stock_warehouse_calendar/readme/USAGE.md @@ -0,0 +1,7 @@ +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. diff --git a/stock_warehouse_calendar/static/description/icon.png b/stock_warehouse_calendar/static/description/icon.png new file mode 100644 index 000000000000..3a0328b516c4 Binary files /dev/null and b/stock_warehouse_calendar/static/description/icon.png differ diff --git a/stock_warehouse_calendar/static/description/index.html b/stock_warehouse_calendar/static/description/index.html new file mode 100644 index 000000000000..4921909e99db --- /dev/null +++ b/stock_warehouse_calendar/static/description/index.html @@ -0,0 +1,457 @@ + + + + + + +Stock Warehouse Calendar + + + +
+

Stock Warehouse Calendar

+ + +

Production/Stable License: LGPL-3 OCA/stock-logistics-warehouse Translate me on Weblate Try me on Runboat

+

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

+ +
+

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. +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.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Authors

+
    +
  • ForgeFlow
  • +
+
+ +
+

Maintainers

+

This module is maintained by the OCA.

+Odoo Community Association +

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.

+

Current maintainer:

+

JordiBForgeFlow

+

This module is part of the OCA/stock-logistics-warehouse project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ + diff --git a/stock_warehouse_calendar/tests/__init__.py b/stock_warehouse_calendar/tests/__init__.py new file mode 100644 index 000000000000..a9c56aa8ed31 --- /dev/null +++ b/stock_warehouse_calendar/tests/__init__.py @@ -0,0 +1 @@ +from . import test_stock_warehouse_calendar diff --git a/stock_warehouse_calendar/tests/test_stock_warehouse_calendar.py b/stock_warehouse_calendar/tests/test_stock_warehouse_calendar.py new file mode 100644 index 000000000000..66bb1e9cdde5 --- /dev/null +++ b/stock_warehouse_calendar/tests/test_stock_warehouse_calendar.py @@ -0,0 +1,122 @@ +# 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 fields +from odoo.tests.common import TransactionCase + + +class TestStockWarehouseCalendar(TransactionCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.env = cls.env(context=dict(cls.env.context, tracking_disable=True)) + cls.wh_obj = cls.env["stock.warehouse"] + cls.move_obj = cls.env["stock.move"] + cls.pg_obj = cls.env["procurement.group"] + + cls.company = cls.env.ref("base.main_company") + cls.warehouse = cls.env.ref("stock.warehouse0") + cls.customer_loc = cls.env.ref("stock.stock_location_customers") + cls.company_partner = cls.env.ref("base.main_partner") + cls.calendar = cls.env.ref("resource.resource_calendar_std") + cls.warehouse.calendar_id = cls.calendar + cls.warehouse_2 = cls.wh_obj.create( + {"code": "WH-T", "name": "Warehouse Test", "calendar_id": cls.calendar.id} + ) + cls.warehouse_3 = cls.wh_obj.create( + {"code": "WH-no-calendar", "name": "Warehouse Test 2"} + ) + + cls.product = cls.env["product.product"].create( + {"name": "test product", "default_code": "PRD", "type": "product"} + ) + + route_vals = {"name": "WH2 -> WH"} + cls.transfer_route = cls.env["stock.route"].create(route_vals) + rule_vals = { + "location_dest_id": cls.warehouse.lot_stock_id.id, + "location_src_id": cls.warehouse_2.lot_stock_id.id, + "action": "pull_push", + "warehouse_id": cls.warehouse.id, + "propagate_warehouse_id": cls.warehouse_2.id, + "picking_type_id": cls.env.ref("stock.picking_type_internal").id, + "name": "WH2->WH", + "route_id": cls.transfer_route.id, + "delay": 1, + } + cls.transfer_rule = cls.env["stock.rule"].create(rule_vals) + cls.product.route_ids = [(6, 0, cls.transfer_route.ids)] + + def test_01_procurement_with_calendar(self): + values = { + "date_planned": "2097-01-07 09:00:00", # Monday + "warehouse_id": self.warehouse, + "company_id": self.company, + "rule_id": self.transfer_rule, + } + self.pg_obj.run( + [ + self.pg_obj.Procurement( + self.product, + 100, + self.product.uom_id, + self.warehouse.lot_stock_id, + "Test", + "Test", + self.warehouse.company_id, + values, + ) + ] + ) + move = self.env["stock.move"].search( + [("product_id", "=", self.product.id)], limit=1 + ) + date = fields.Date.to_date(move.date) + # Friday 4th Jan 2017 + friday = fields.Date.to_date("2097-01-04 09:00:00") + + self.assertEqual(date, friday) + + def test_02_procurement_with_calendar_early(self): + """Test procuring at the beginning of the day, with no work intervals + before.""" + values = { + "date_planned": "2097-01-07 01:00:00", # Monday + "warehouse_id": self.warehouse, + "company_id": self.company, + "rule_id": self.transfer_rule, + } + self.pg_obj.run( + [ + self.pg_obj.Procurement( + self.product, + 100, + self.product.uom_id, + self.warehouse.lot_stock_id, + "Test", + "Test", + self.warehouse.company_id, + values, + ) + ] + ) + move = self.env["stock.move"].search( + [("product_id", "=", self.product.id)], limit=1 + ) + date = fields.Date.to_date(move.date) + # Friday 4th Jan 2017 + friday = fields.Date.to_date("2097-01-04 09:00:00") + + self.assertEqual(date, friday) + + def test_03_wh_plan_days_future(self): + """Test plan days helper in warehouse.""" + reference = "2097-01-09 12:00:00" # Wednesday + # With calendar + result = self.warehouse_2.wh_plan_days(reference, 3).date() + next_monday = fields.Date.to_date("2097-01-14") + self.assertEqual(result, next_monday) + # Without calendar + result = self.warehouse_3.wh_plan_days(reference, 3).date() + saturday = fields.Date.to_date("2097-01-12") + self.assertEqual(result, saturday) diff --git a/stock_warehouse_calendar/views/stock_warehouse_views.xml b/stock_warehouse_calendar/views/stock_warehouse_views.xml new file mode 100644 index 000000000000..168e995a5acc --- /dev/null +++ b/stock_warehouse_calendar/views/stock_warehouse_views.xml @@ -0,0 +1,15 @@ + + + + + stock.warehouse + stock.warehouse + + + + + + + +