diff --git a/setup/stock_picking_group_by_partner_by_carrier_by_date/odoo/addons/stock_picking_group_by_partner_by_carrier_by_date b/setup/stock_picking_group_by_partner_by_carrier_by_date/odoo/addons/stock_picking_group_by_partner_by_carrier_by_date new file mode 120000 index 000000000000..3bd81e77608e --- /dev/null +++ b/setup/stock_picking_group_by_partner_by_carrier_by_date/odoo/addons/stock_picking_group_by_partner_by_carrier_by_date @@ -0,0 +1 @@ +../../../../stock_picking_group_by_partner_by_carrier_by_date \ No newline at end of file diff --git a/setup/stock_picking_group_by_partner_by_carrier_by_date/setup.py b/setup/stock_picking_group_by_partner_by_carrier_by_date/setup.py new file mode 100644 index 000000000000..28c57bb64031 --- /dev/null +++ b/setup/stock_picking_group_by_partner_by_carrier_by_date/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +) diff --git a/stock_picking_group_by_partner_by_carrier_by_date/README.rst b/stock_picking_group_by_partner_by_carrier_by_date/README.rst new file mode 100644 index 000000000000..71e7ce741b6d --- /dev/null +++ b/stock_picking_group_by_partner_by_carrier_by_date/README.rst @@ -0,0 +1,98 @@ +============================================================== +Stock Picking: group by partner and carrier and scheduled date +============================================================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:e7c76c2b68fdb9355b885ad9bbc225bafc6f8014d92df44108e674dd0bb80fbb + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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%2Fstock--logistics--workflow-lightgray.png?logo=github + :target: https://github.com/OCA/stock-logistics-workflow/tree/16.0/stock_picking_group_by_partner_by_carrier_by_date + :alt: OCA/stock-logistics-workflow +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/stock-logistics-workflow-16-0/stock-logistics-workflow-16-0-stock_picking_group_by_partner_by_carrier_by_date + :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-workflow&target_branch=16.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +Group delivery orders by partner, carrier and scheduled date. + +.. 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 `_ + +**Table of contents** + +.. contents:: + :local: + +Usage +===== + +See `stock_picking_group_by_partner_by_carrier` configuration. + +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 +~~~~~~~ + +* Camptocamp + +Contributors +~~~~~~~~~~~~ + +* Simone Orsi + +* Camptocamp: + * Joël Grand-Guillaume + +* Phuc Tran Thanh + +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. + +This module is part of the `OCA/stock-logistics-workflow `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/stock_picking_group_by_partner_by_carrier_by_date/__init__.py b/stock_picking_group_by_partner_by_carrier_by_date/__init__.py new file mode 100644 index 000000000000..0650744f6bc6 --- /dev/null +++ b/stock_picking_group_by_partner_by_carrier_by_date/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/stock_picking_group_by_partner_by_carrier_by_date/__manifest__.py b/stock_picking_group_by_partner_by_carrier_by_date/__manifest__.py new file mode 100644 index 000000000000..ca9c6e94a6db --- /dev/null +++ b/stock_picking_group_by_partner_by_carrier_by_date/__manifest__.py @@ -0,0 +1,20 @@ +# Copyright 2020 Camptocamp +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +{ + "name": "Stock Picking: group by partner and carrier and scheduled date", + "Summary": """Delivery orders will be matched by date too. + """, + "version": "16.0.1.0.0", + "development_status": "Alpha", + "author": "Camptocamp, Odoo Community Association (OCA)", + "website": "https://github.com/OCA/stock-logistics-workflow", + "category": "Warehouse Management", + # TODO: consider splitting the hook for `_assign_picking` defined in + # `stock_picking_group_by_partner_by_carrier` + # to avoid depending on `stock_picking_group_by_partner_by_carrier`. + "depends": ["partner_tz", "stock_picking_group_by_partner_by_carrier"], + "data": ["views/stock_picking_type.xml"], + "installable": True, + "license": "AGPL-3", +} diff --git a/stock_picking_group_by_partner_by_carrier_by_date/i18n/it.po b/stock_picking_group_by_partner_by_carrier_by_date/i18n/it.po new file mode 100644 index 000000000000..89e0df2d3e2f --- /dev/null +++ b/stock_picking_group_by_partner_by_carrier_by_date/i18n/it.po @@ -0,0 +1,55 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * stock_picking_group_by_partner_by_carrier_by_date +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 14.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2023-12-26 14: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_picking_group_by_partner_by_carrier_by_date +#: model:ir.model.fields,field_description:stock_picking_group_by_partner_by_carrier_by_date.field_stock_move__display_name +#: model:ir.model.fields,field_description:stock_picking_group_by_partner_by_carrier_by_date.field_stock_picking_type__display_name +msgid "Display Name" +msgstr "Nome visualizzato" + +#. module: stock_picking_group_by_partner_by_carrier_by_date +#: model:ir.model.fields,field_description:stock_picking_group_by_partner_by_carrier_by_date.field_stock_picking_type__group_pickings_by_date +msgid "Group pickings by date" +msgstr "Raggruppa prelievi per data" + +#. module: stock_picking_group_by_partner_by_carrier_by_date +#: model:ir.model.fields,field_description:stock_picking_group_by_partner_by_carrier_by_date.field_stock_move__id +#: model:ir.model.fields,field_description:stock_picking_group_by_partner_by_carrier_by_date.field_stock_picking_type__id +msgid "ID" +msgstr "ID" + +#. module: stock_picking_group_by_partner_by_carrier_by_date +#: model:ir.model.fields,help:stock_picking_group_by_partner_by_carrier_by_date.field_stock_picking_type__group_pickings_by_date +msgid "If `Group pickings` is enabled they will be grouped by date too." +msgstr "Se `Raggruppa prelievi`è abilitato verranno raggruppati ancheper data." + +#. module: stock_picking_group_by_partner_by_carrier_by_date +#: model:ir.model.fields,field_description:stock_picking_group_by_partner_by_carrier_by_date.field_stock_move____last_update +#: model:ir.model.fields,field_description:stock_picking_group_by_partner_by_carrier_by_date.field_stock_picking_type____last_update +msgid "Last Modified on" +msgstr "Ultima modifica il" + +#. module: stock_picking_group_by_partner_by_carrier_by_date +#: model:ir.model,name:stock_picking_group_by_partner_by_carrier_by_date.model_stock_picking_type +msgid "Picking Type" +msgstr "Tipologia prelievo" + +#. module: stock_picking_group_by_partner_by_carrier_by_date +#: model:ir.model,name:stock_picking_group_by_partner_by_carrier_by_date.model_stock_move +msgid "Stock Move" +msgstr "Movimento di magazzino" diff --git a/stock_picking_group_by_partner_by_carrier_by_date/i18n/stock_picking_group_by_partner_by_carrier_by_date.pot b/stock_picking_group_by_partner_by_carrier_by_date/i18n/stock_picking_group_by_partner_by_carrier_by_date.pot new file mode 100644 index 000000000000..6f7f715ca938 --- /dev/null +++ b/stock_picking_group_by_partner_by_carrier_by_date/i18n/stock_picking_group_by_partner_by_carrier_by_date.pot @@ -0,0 +1,52 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * stock_picking_group_by_partner_by_carrier_by_date +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 14.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_picking_group_by_partner_by_carrier_by_date +#: model:ir.model.fields,field_description:stock_picking_group_by_partner_by_carrier_by_date.field_stock_move__display_name +#: model:ir.model.fields,field_description:stock_picking_group_by_partner_by_carrier_by_date.field_stock_picking_type__display_name +msgid "Display Name" +msgstr "" + +#. module: stock_picking_group_by_partner_by_carrier_by_date +#: model:ir.model.fields,field_description:stock_picking_group_by_partner_by_carrier_by_date.field_stock_picking_type__group_pickings_by_date +msgid "Group pickings by date" +msgstr "" + +#. module: stock_picking_group_by_partner_by_carrier_by_date +#: model:ir.model.fields,field_description:stock_picking_group_by_partner_by_carrier_by_date.field_stock_move__id +#: model:ir.model.fields,field_description:stock_picking_group_by_partner_by_carrier_by_date.field_stock_picking_type__id +msgid "ID" +msgstr "" + +#. module: stock_picking_group_by_partner_by_carrier_by_date +#: model:ir.model.fields,help:stock_picking_group_by_partner_by_carrier_by_date.field_stock_picking_type__group_pickings_by_date +msgid "If `Group pickings` is enabled they will be grouped by date too." +msgstr "" + +#. module: stock_picking_group_by_partner_by_carrier_by_date +#: model:ir.model.fields,field_description:stock_picking_group_by_partner_by_carrier_by_date.field_stock_move____last_update +#: model:ir.model.fields,field_description:stock_picking_group_by_partner_by_carrier_by_date.field_stock_picking_type____last_update +msgid "Last Modified on" +msgstr "" + +#. module: stock_picking_group_by_partner_by_carrier_by_date +#: model:ir.model,name:stock_picking_group_by_partner_by_carrier_by_date.model_stock_picking_type +msgid "Picking Type" +msgstr "" + +#. module: stock_picking_group_by_partner_by_carrier_by_date +#: model:ir.model,name:stock_picking_group_by_partner_by_carrier_by_date.model_stock_move +msgid "Stock Move" +msgstr "" diff --git a/stock_picking_group_by_partner_by_carrier_by_date/models/__init__.py b/stock_picking_group_by_partner_by_carrier_by_date/models/__init__.py new file mode 100644 index 000000000000..90f60bebb8fa --- /dev/null +++ b/stock_picking_group_by_partner_by_carrier_by_date/models/__init__.py @@ -0,0 +1,2 @@ +from . import stock_move +from . import stock_picking_type diff --git a/stock_picking_group_by_partner_by_carrier_by_date/models/stock_move.py b/stock_picking_group_by_partner_by_carrier_by_date/models/stock_move.py new file mode 100644 index 000000000000..d3d0398ae4fd --- /dev/null +++ b/stock_picking_group_by_partner_by_carrier_by_date/models/stock_move.py @@ -0,0 +1,53 @@ +# Copyright 2020 Camptocamp (https://www.camptocamp.com) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from datetime import timedelta + +from odoo import models + +from odoo.addons.partner_tz.tools.tz_utils import ( + tz_to_utc_naive_datetime, + utc_to_tz_naive_datetime, +) + + +class StockMove(models.Model): + _inherit = "stock.move" + + def _assign_picking_group_domain(self): + domain = super()._assign_picking_group_domain() + by_date_domain = self._assign_picking_group_domain_by_date() + domain.extend(by_date_domain) + return domain + + def _skip_assign_picking_group_domain_by_date(self): + return ( + not self.picking_type_id.group_pickings_by_date + or not self.picking_type_id.group_pickings + or self.group_id.sale_id.picking_policy == "one" + or self.env.context.get("picking_manual_merge") + ) + + def _assign_picking_group_domain_by_date(self): + domain = [] + if self._skip_assign_picking_group_domain_by_date(): + return domain + tz = ( + self.warehouse_id.partner_id.tz + or self.env.company.partner_id.tz + or self.env.user.tz + ) + date_tz = utc_to_tz_naive_datetime(tz, self.date) + dt_start_tz = date_tz.replace( + hour=0, + minute=0, + second=0, + microsecond=0, + ) + dt_start = tz_to_utc_naive_datetime(tz, dt_start_tz) + dt_end = dt_start + timedelta(days=1) + domain = [ + ("scheduled_date", "<", dt_end), + ("scheduled_date", ">=", dt_start), + ] + return domain diff --git a/stock_picking_group_by_partner_by_carrier_by_date/models/stock_picking_type.py b/stock_picking_group_by_partner_by_carrier_by_date/models/stock_picking_type.py new file mode 100644 index 000000000000..ce04aaa3ac5a --- /dev/null +++ b/stock_picking_group_by_partner_by_carrier_by_date/models/stock_picking_type.py @@ -0,0 +1,10 @@ +from odoo import fields, models + + +class StockPickingType(models.Model): + _inherit = "stock.picking.type" + + group_pickings_by_date = fields.Boolean( + "Group pickings by date", + help="If `Group pickings` is enabled they will be grouped by date too.", + ) diff --git a/stock_picking_group_by_partner_by_carrier_by_date/readme/CONTRIBUTORS.rst b/stock_picking_group_by_partner_by_carrier_by_date/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000000..d1988c6f2bc6 --- /dev/null +++ b/stock_picking_group_by_partner_by_carrier_by_date/readme/CONTRIBUTORS.rst @@ -0,0 +1,6 @@ +* Simone Orsi + +* Camptocamp: + * Joël Grand-Guillaume + +* Phuc Tran Thanh diff --git a/stock_picking_group_by_partner_by_carrier_by_date/readme/CREDITS.rst b/stock_picking_group_by_partner_by_carrier_by_date/readme/CREDITS.rst new file mode 100644 index 000000000000..f5cc070c78ea --- /dev/null +++ b/stock_picking_group_by_partner_by_carrier_by_date/readme/CREDITS.rst @@ -0,0 +1,3 @@ +The development of this module has been financially supported by: + +* Camptocamp diff --git a/stock_picking_group_by_partner_by_carrier_by_date/readme/DESCRIPTION.rst b/stock_picking_group_by_partner_by_carrier_by_date/readme/DESCRIPTION.rst new file mode 100644 index 000000000000..0d00d2f1dfcf --- /dev/null +++ b/stock_picking_group_by_partner_by_carrier_by_date/readme/DESCRIPTION.rst @@ -0,0 +1 @@ +Group delivery orders by partner, carrier and scheduled date. diff --git a/stock_picking_group_by_partner_by_carrier_by_date/readme/USAGE.rst b/stock_picking_group_by_partner_by_carrier_by_date/readme/USAGE.rst new file mode 100644 index 000000000000..46e9e00b03cf --- /dev/null +++ b/stock_picking_group_by_partner_by_carrier_by_date/readme/USAGE.rst @@ -0,0 +1 @@ +See `stock_picking_group_by_partner_by_carrier` configuration. diff --git a/stock_picking_group_by_partner_by_carrier_by_date/static/description/icon.png b/stock_picking_group_by_partner_by_carrier_by_date/static/description/icon.png new file mode 100644 index 000000000000..3a0328b516c4 Binary files /dev/null and b/stock_picking_group_by_partner_by_carrier_by_date/static/description/icon.png differ diff --git a/stock_picking_group_by_partner_by_carrier_by_date/static/description/index.html b/stock_picking_group_by_partner_by_carrier_by_date/static/description/index.html new file mode 100644 index 000000000000..52e3c558aacf --- /dev/null +++ b/stock_picking_group_by_partner_by_carrier_by_date/static/description/index.html @@ -0,0 +1,442 @@ + + + + + +Stock Picking: group by partner and carrier and scheduled date + + + +
+

Stock Picking: group by partner and carrier and scheduled date

+ + +

Alpha License: AGPL-3 OCA/stock-logistics-workflow Translate me on Weblate Try me on Runboat

+

Group delivery orders by partner, carrier and scheduled date.

+
+

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

+
+

Table of contents

+ +
+

Usage

+

See stock_picking_group_by_partner_by_carrier configuration.

+
+
+

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

+
    +
  • Camptocamp
  • +
+
+
+

Contributors

+ +
+
+

Other credits

+

The development of this module has been financially supported by:

+
    +
  • Camptocamp
  • +
+
+
+

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.

+

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

+

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

+
+
+
+ + diff --git a/stock_picking_group_by_partner_by_carrier_by_date/tests/__init__.py b/stock_picking_group_by_partner_by_carrier_by_date/tests/__init__.py new file mode 100644 index 000000000000..d5ba83e8f9a9 --- /dev/null +++ b/stock_picking_group_by_partner_by_carrier_by_date/tests/__init__.py @@ -0,0 +1 @@ +from . import test_grouping_by_date diff --git a/stock_picking_group_by_partner_by_carrier_by_date/tests/test_grouping_by_date.py b/stock_picking_group_by_partner_by_carrier_by_date/tests/test_grouping_by_date.py new file mode 100644 index 000000000000..82d144692656 --- /dev/null +++ b/stock_picking_group_by_partner_by_carrier_by_date/tests/test_grouping_by_date.py @@ -0,0 +1,96 @@ +# Copyright 2020 Camptocamp SA +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl) +from freezegun import freeze_time + +from odoo.tests import TransactionCase, tagged + + +class TestGroupByDateBase(TransactionCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.env = cls.env(context=dict(cls.env.context, tracking_disable=True)) + cls.partner = cls.env.ref("base.res_partner_12") + cls.product = cls.env.ref("product.product_product_9") + cls.warehouse = cls.env.ref("stock.warehouse0") + cls.warehouse.out_type_id.group_pickings = True + cls.warehouse.out_type_id.group_pickings_by_date = True + + def _create_order(self, partner=None): + order = self.env["sale.order"].create( + { + "partner_id": partner.id, + "partner_shipping_id": partner.id, + "order_line": [ + ( + 0, + 0, + { + "name": self.product.name, + "product_id": self.product.id, + "product_uom_qty": 1, + "product_uom": self.product.uom_id.id, + "price_unit": self.product.list_price, + }, + ) + ], + } + ) + return order + + +@tagged("post_install", "-at_install") +class TestGroupByDate(TestGroupByDateBase): + def _create_orders_and_pickings(self): + order1 = self._create_order(partner=self.partner) + order1.action_confirm() + picking1 = order1.picking_ids + order2 = self._create_order(partner=self.partner) + order2.action_confirm() + picking2 = order2.picking_ids + return picking1, picking2 + + def test_group_by_date(self): + # Schedule orders for tomorrow + with freeze_time("2020-11-27 12:00:00"): + p1, p2 = self._create_orders_and_pickings() + self.assertEqual(p1, p2) + + # Same day + with freeze_time("2020-11-27 11:00:00"): + p3, p4 = self._create_orders_and_pickings() + self.assertEqual(p3, p4) + self.assertEqual(p3, p1) + + # Same day, one minute later + with freeze_time("2020-11-27 11:01:00"): + p5, p6 = self._create_orders_and_pickings() + self.assertEqual(p5, p6) + self.assertEqual(p5, p1) + + # Delay 1st picking date + p1.scheduled_date = "2020-11-27 18:30:00" + with freeze_time("2020-11-27 18:00:00"): + p5, p6 = self._create_orders_and_pickings() + self.assertEqual(p5, p6) + self.assertEqual(p5, p1) + + # Previous day + with freeze_time("2020-11-26 08:00:00"): + p7, p8 = self._create_orders_and_pickings() + self.assertEqual(p7, p8) + self.assertNotEqual(p7, p1) + + # Day after + with freeze_time("2020-11-28 14:00:00"): + p9, p10 = self._create_orders_and_pickings() + self.assertEqual(p9, p10) + self.assertNotEqual(p9, p1) + + # With tz + p1.scheduled_date = "2020-11-28 18:30:00" + with freeze_time("2020-11-28 18:00:00"): + self.warehouse.partner_id.tz = "Asia/Hong_Kong" + p11, p12 = self._create_orders_and_pickings() + self.assertEqual(p11, p12) + self.assertEqual(p11, p1) diff --git a/stock_picking_group_by_partner_by_carrier_by_date/views/stock_picking_type.xml b/stock_picking_group_by_partner_by_carrier_by_date/views/stock_picking_type.xml new file mode 100644 index 000000000000..9609af6c5ed2 --- /dev/null +++ b/stock_picking_group_by_partner_by_carrier_by_date/views/stock_picking_type.xml @@ -0,0 +1,12 @@ + + + + stock.picking.type + + + + + + + +