From ef3d23a9dfb7eb22ea0c35176cc8e78318199ab7 Mon Sep 17 00:00:00 2001 From: Pierre Verkest Date: Fri, 1 Mar 2024 17:58:18 +0100 Subject: [PATCH] =?UTF-8?q?[ADD]=C2=A0sale=5Fstock=5Fservice=5Flevel?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sale_stock_service_level/README.rst | 83 ++++ sale_stock_service_level/__init__.py | 1 + sale_stock_service_level/__manifest__.py | 21 + sale_stock_service_level/i18n/fr.po | 55 +++ .../i18n/sale_stock_service_level.pot | 54 +++ sale_stock_service_level/models/__init__.py | 2 + sale_stock_service_level/models/sale_order.py | 15 + .../models/sale_order_line.py | 21 + .../readme/CONTRIBUTORS.rst | 1 + .../readme/DESCRIPTION.rst | 8 + .../static/description/index.html | 426 ++++++++++++++++++ sale_stock_service_level/tests/__init__.py | 1 + .../tests/test_sale_stock_service_level.py | 61 +++ .../views/sale_order_views.xml | 15 + .../odoo/addons/sale_stock_service_level | 1 + setup/sale_stock_service_level/setup.py | 6 + 16 files changed, 771 insertions(+) create mode 100644 sale_stock_service_level/README.rst create mode 100644 sale_stock_service_level/__init__.py create mode 100644 sale_stock_service_level/__manifest__.py create mode 100644 sale_stock_service_level/i18n/fr.po create mode 100644 sale_stock_service_level/i18n/sale_stock_service_level.pot create mode 100644 sale_stock_service_level/models/__init__.py create mode 100644 sale_stock_service_level/models/sale_order.py create mode 100644 sale_stock_service_level/models/sale_order_line.py create mode 100644 sale_stock_service_level/readme/CONTRIBUTORS.rst create mode 100644 sale_stock_service_level/readme/DESCRIPTION.rst create mode 100644 sale_stock_service_level/static/description/index.html create mode 100644 sale_stock_service_level/tests/__init__.py create mode 100644 sale_stock_service_level/tests/test_sale_stock_service_level.py create mode 100644 sale_stock_service_level/views/sale_order_views.xml create mode 120000 setup/sale_stock_service_level/odoo/addons/sale_stock_service_level create mode 100644 setup/sale_stock_service_level/setup.py diff --git a/sale_stock_service_level/README.rst b/sale_stock_service_level/README.rst new file mode 100644 index 00000000000..15c84de4c71 --- /dev/null +++ b/sale_stock_service_level/README.rst @@ -0,0 +1,83 @@ +======================== +Sale stock service level +======================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:c925c696b7866773844deafce7ac088e419738df69f711b126b0bed6fd7fb530 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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%2Fsale--workflow-lightgray.png?logo=github + :target: https://github.com/OCA/sale-workflow/tree/14.0/sale_stock_service_level + :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-14-0/sale-workflow-14-0-sale_stock_service_level + :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/sale-workflow&target_branch=14.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This offer a default behavior while confirming sale order to set the +**stock service level** to be use by `stock_service_level` (and +`stock_service_level_route`) modules. + +This module add a computed field on sale order line that can be adapted to your needs. + +This service level is used while calling the procurement method while confirming the sale order +and propagated to stock.move in order to apply rule or reservation rule on it. + +**Table of contents** + +.. contents:: + :local: + +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 +~~~~~~~ + +* Pierre Verkest + +Contributors +~~~~~~~~~~~~ + +* Pierre Verkest + +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 `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/sale_stock_service_level/__init__.py b/sale_stock_service_level/__init__.py new file mode 100644 index 00000000000..0650744f6bc --- /dev/null +++ b/sale_stock_service_level/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/sale_stock_service_level/__manifest__.py b/sale_stock_service_level/__manifest__.py new file mode 100644 index 00000000000..81cae0361a7 --- /dev/null +++ b/sale_stock_service_level/__manifest__.py @@ -0,0 +1,21 @@ +# Copyright 2024 Foodles (https://www.foodles.co) +# @author Pierre Verkest +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +{ + "name": "Sale stock service level", + "Summary": "Sale different service level per products.", + "version": "14.0.0.1.0", + "development_status": "Beta", + "author": "Pierre Verkest , Odoo Community Association (OCA)", + "website": "https://github.com/OCA/sale-workflow", + "category": "Warehouse Management", + "depends": [ + "sale_stock", + "stock_service_level", + ], + "installable": True, + "license": "AGPL-3", + "data": [ + "views/sale_order_views.xml", + ], +} diff --git a/sale_stock_service_level/i18n/fr.po b/sale_stock_service_level/i18n/fr.po new file mode 100644 index 00000000000..1f729b4b316 --- /dev/null +++ b/sale_stock_service_level/i18n/fr.po @@ -0,0 +1,55 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * sale_stock_service_level +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 14.0+e\n" +"Report-Msgid-Bugs-To: \n" +"Last-Translator: \n" +"Language-Team: \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: sale_stock_service_level +#: model:ir.model.fields,field_description:sale_stock_service_level.field_sale_order__display_name +#: model:ir.model.fields,field_description:sale_stock_service_level.field_sale_order_line__display_name +msgid "Display Name" +msgstr "Libellé" + +#. module: sale_stock_service_level +#: model:ir.model.fields,field_description:sale_stock_service_level.field_sale_order__id +#: model:ir.model.fields,field_description:sale_stock_service_level.field_sale_order_line__id +msgid "ID" +msgstr "" + +#. module: sale_stock_service_level +#: model:ir.model.fields,field_description:sale_stock_service_level.field_sale_order____last_update +#: model:ir.model.fields,field_description:sale_stock_service_level.field_sale_order_line____last_update +msgid "Last Modified on" +msgstr "Dernière date de modification" + +#. module: sale_stock_service_level +#: model:ir.model,name:sale_stock_service_level.model_sale_order +msgid "Sales Order" +msgstr "Devis/Commande" + +#. module: sale_stock_service_level +#: model:ir.model,name:sale_stock_service_level.model_sale_order_line +msgid "Sales Order Line" +msgstr "Ligne de commande" + +#. module: sale_stock_service_level +#: model:ir.model.fields,field_description:sale_stock_service_level.field_sale_order__service_level_id +#: model:ir.model.fields,field_description:sale_stock_service_level.field_sale_order_line__service_level_id +msgid "Service level" +msgstr "Prestation" + +#. module: sale_stock_service_level +#: model:ir.model.fields,help:sale_stock_service_level.field_sale_order__service_level_id +#: model:ir.model.fields,help:sale_stock_service_level.field_sale_order_line__service_level_id +msgid "The service level." +msgstr "Prestation" diff --git a/sale_stock_service_level/i18n/sale_stock_service_level.pot b/sale_stock_service_level/i18n/sale_stock_service_level.pot new file mode 100644 index 00000000000..44ee08b0ae4 --- /dev/null +++ b/sale_stock_service_level/i18n/sale_stock_service_level.pot @@ -0,0 +1,54 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * sale_stock_service_level +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 14.0+e\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: sale_stock_service_level +#: model:ir.model.fields,field_description:sale_stock_service_level.field_sale_order__display_name +#: model:ir.model.fields,field_description:sale_stock_service_level.field_sale_order_line__display_name +msgid "Display Name" +msgstr "" + +#. module: sale_stock_service_level +#: model:ir.model.fields,field_description:sale_stock_service_level.field_sale_order__id +#: model:ir.model.fields,field_description:sale_stock_service_level.field_sale_order_line__id +msgid "ID" +msgstr "" + +#. module: sale_stock_service_level +#: model:ir.model.fields,field_description:sale_stock_service_level.field_sale_order____last_update +#: model:ir.model.fields,field_description:sale_stock_service_level.field_sale_order_line____last_update +msgid "Last Modified on" +msgstr "" + +#. module: sale_stock_service_level +#: model:ir.model,name:sale_stock_service_level.model_sale_order +msgid "Sales Order" +msgstr "" + +#. module: sale_stock_service_level +#: model:ir.model,name:sale_stock_service_level.model_sale_order_line +msgid "Sales Order Line" +msgstr "" + +#. module: sale_stock_service_level +#: model:ir.model.fields,field_description:sale_stock_service_level.field_sale_order__service_level_id +#: model:ir.model.fields,field_description:sale_stock_service_level.field_sale_order_line__service_level_id +msgid "Service level" +msgstr "" + +#. module: sale_stock_service_level +#: model:ir.model.fields,help:sale_stock_service_level.field_sale_order__service_level_id +#: model:ir.model.fields,help:sale_stock_service_level.field_sale_order_line__service_level_id +msgid "The service level." +msgstr "" diff --git a/sale_stock_service_level/models/__init__.py b/sale_stock_service_level/models/__init__.py new file mode 100644 index 00000000000..e7e9273fcff --- /dev/null +++ b/sale_stock_service_level/models/__init__.py @@ -0,0 +1,2 @@ +from . import sale_order_line +from . import sale_order diff --git a/sale_stock_service_level/models/sale_order.py b/sale_stock_service_level/models/sale_order.py new file mode 100644 index 00000000000..49b35a77521 --- /dev/null +++ b/sale_stock_service_level/models/sale_order.py @@ -0,0 +1,15 @@ +# Copyright 2024 Foodles (https://www.foodles.co) +# @author Pierre Verkest +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +from odoo import fields, models + + +class SaleOrder(models.Model): + _inherit = "sale.order" + + service_level_id = fields.Many2one( + string="Service level", + index="btree_not_null", + comodel_name="stock.service.level", + help="The service level.", + ) diff --git a/sale_stock_service_level/models/sale_order_line.py b/sale_stock_service_level/models/sale_order_line.py new file mode 100644 index 00000000000..8170beb1557 --- /dev/null +++ b/sale_stock_service_level/models/sale_order_line.py @@ -0,0 +1,21 @@ +# Copyright 2024 Foodles (https://www.foodles.co) +# @author Pierre Verkest +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +from odoo import fields, models + + +class SaleOrderLine(models.Model): + _inherit = "sale.order.line" + + service_level_id = fields.Many2one( + comodel_name="stock.service.level", + string="Service level", + related="order_id.service_level_id", + help="The service level.", + ) + + def _prepare_procurement_values(self, group_id=False): + return { + **super()._prepare_procurement_values(group_id=group_id), + "service_level_id": self.service_level_id.id, + } diff --git a/sale_stock_service_level/readme/CONTRIBUTORS.rst b/sale_stock_service_level/readme/CONTRIBUTORS.rst new file mode 100644 index 00000000000..638be866310 --- /dev/null +++ b/sale_stock_service_level/readme/CONTRIBUTORS.rst @@ -0,0 +1 @@ +* Pierre Verkest diff --git a/sale_stock_service_level/readme/DESCRIPTION.rst b/sale_stock_service_level/readme/DESCRIPTION.rst new file mode 100644 index 00000000000..53a91f4b539 --- /dev/null +++ b/sale_stock_service_level/readme/DESCRIPTION.rst @@ -0,0 +1,8 @@ +This offer a default behavior while confirming sale order to set the +**stock service level** to be use by `stock_service_level` (and +`stock_service_level_route`) modules. + +This module add a computed field on sale order line that can be adapted to your needs. + +This service level is used while calling the procurement method while confirming the sale order +and propagated to stock.move in order to apply rule or reservation rule on it. diff --git a/sale_stock_service_level/static/description/index.html b/sale_stock_service_level/static/description/index.html new file mode 100644 index 00000000000..a2d525956b4 --- /dev/null +++ b/sale_stock_service_level/static/description/index.html @@ -0,0 +1,426 @@ + + + + + + +Sale stock service level + + + +
+

Sale stock service level

+ + +

Beta License: AGPL-3 OCA/sale-workflow Translate me on Weblate Try me on Runboat

+

This offer a default behavior while confirming sale order to set the +stock service level to be use by stock_service_level (and +stock_service_level_route) modules.

+

This module add a computed field on sale order line that can be adapted to your needs.

+

This service level is used while calling the procurement method while confirming the sale order +and propagated to stock.move in order to apply rule or reservation rule on it.

+

Table of contents

+ +
+

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

+ +
+
+

Contributors

+ +
+
+

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/sale-workflow project on GitHub.

+

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

+
+
+
+ + diff --git a/sale_stock_service_level/tests/__init__.py b/sale_stock_service_level/tests/__init__.py new file mode 100644 index 00000000000..22c81e920c8 --- /dev/null +++ b/sale_stock_service_level/tests/__init__.py @@ -0,0 +1 @@ +from . import test_sale_stock_service_level diff --git a/sale_stock_service_level/tests/test_sale_stock_service_level.py b/sale_stock_service_level/tests/test_sale_stock_service_level.py new file mode 100644 index 00000000000..9641b513fbf --- /dev/null +++ b/sale_stock_service_level/tests/test_sale_stock_service_level.py @@ -0,0 +1,61 @@ +# Copyright 2024 Foodles (https://www.foodles.co) +# @author Pierre Verkest +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +from odoo.tests.common import SavepointCase + + +class SaleOrderServiceLevelTest(SavepointCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.partner = cls.env["res.partner"].create({"name": "Test"}) + cls.product1 = cls.env["product.product"].create( + {"name": "test_product1", "type": "product"} + ) + cls.service_level_sdt = cls.env["stock.service.level"].create( + { + "name": "Standard", + "code": "STD", + } + ) + cls.order = cls.env["sale.order"].create( + [ + { + "partner_id": cls.partner.id, + "commitment_date": "2024-02-02", + "service_level_id": cls.service_level_sdt.id, + "order_line": [ + ( + 0, + 0, + { + "name": cls.product1.name, + "product_id": cls.product1.id, + "product_uom_qty": 1, + "product_uom": cls.product1.uom_id.id, + }, + ), + ], + }, + ] + ) + + def test_confirm_sale_order_propagate_service_level( + self, + ): + self.order.action_confirm() + delivery = self.order.picking_ids + self.assertEqual( + delivery.move_lines.service_level_id, + self.service_level_sdt, + ) + + def test_confirm_sale_order_without_service_level( + self, + ): + self.order.service_level_id = False + self.order.action_confirm() + delivery = self.order.picking_ids + self.assertFalse( + delivery.move_lines.service_level_id, + ) diff --git a/sale_stock_service_level/views/sale_order_views.xml b/sale_stock_service_level/views/sale_order_views.xml new file mode 100644 index 00000000000..bfba1ed967a --- /dev/null +++ b/sale_stock_service_level/views/sale_order_views.xml @@ -0,0 +1,15 @@ + + + + sale.order.form + sale.order + + 500 + + + + + + + + diff --git a/setup/sale_stock_service_level/odoo/addons/sale_stock_service_level b/setup/sale_stock_service_level/odoo/addons/sale_stock_service_level new file mode 120000 index 00000000000..812a20f9b52 --- /dev/null +++ b/setup/sale_stock_service_level/odoo/addons/sale_stock_service_level @@ -0,0 +1 @@ +../../../../sale_stock_service_level \ No newline at end of file diff --git a/setup/sale_stock_service_level/setup.py b/setup/sale_stock_service_level/setup.py new file mode 100644 index 00000000000..28c57bb6403 --- /dev/null +++ b/setup/sale_stock_service_level/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)