diff --git a/setup/stock_picking_delivery_package_type_domain/odoo/addons/stock_picking_delivery_package_type_domain b/setup/stock_picking_delivery_package_type_domain/odoo/addons/stock_picking_delivery_package_type_domain new file mode 120000 index 0000000000..1c501251f2 --- /dev/null +++ b/setup/stock_picking_delivery_package_type_domain/odoo/addons/stock_picking_delivery_package_type_domain @@ -0,0 +1 @@ +../../../../stock_picking_delivery_package_type_domain \ No newline at end of file diff --git a/setup/stock_picking_delivery_package_type_domain/setup.py b/setup/stock_picking_delivery_package_type_domain/setup.py new file mode 100644 index 0000000000..28c57bb640 --- /dev/null +++ b/setup/stock_picking_delivery_package_type_domain/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +) diff --git a/stock_picking_delivery_package_type_domain/README.rst b/stock_picking_delivery_package_type_domain/README.rst new file mode 100644 index 0000000000..de3d070c9e --- /dev/null +++ b/stock_picking_delivery_package_type_domain/README.rst @@ -0,0 +1,93 @@ +========================================== +Stock Picking Delivery Package Type Domain +========================================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:6fdfaf8638714c22c756a43e4be5e63d5dd63b1d71db39b968f00b7f1abd2f71 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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%2Fdelivery--carrier-lightgray.png?logo=github + :target: https://github.com/OCA/delivery-carrier/tree/16.0/stock_picking_delivery_package_type_domain + :alt: OCA/delivery-carrier +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/delivery-carrier-16-0/delivery-carrier-16-0-stock_picking_delivery_package_type_domain + :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/delivery-carrier&target_branch=16.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module allows to override the available package types during the +put in pack process related to a picking with a delivery carrier filled +in. + +This module is a technical module, does nothing by its own and should be +overriden. + +**Table of contents** + +.. contents:: + :local: + +Use Cases / Context +=================== + +In Odoo delivery module, you can choose the delivery package type if the +carrier is defined on the stock picking. + +The filtered package types displayed are based on the package type +package_carrier_type field. That domain is set on the view and is not +extendable. + +This is why this module changed the domain in view to a computed field. + +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 +------- + +* ACSONE SA/NV + +Contributors +------------ + +- Denis Roussel denis.roussel@acsone.eu + +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/delivery-carrier `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/stock_picking_delivery_package_type_domain/__init__.py b/stock_picking_delivery_package_type_domain/__init__.py new file mode 100644 index 0000000000..5cb1c49143 --- /dev/null +++ b/stock_picking_delivery_package_type_domain/__init__.py @@ -0,0 +1 @@ +from . import wizards diff --git a/stock_picking_delivery_package_type_domain/__manifest__.py b/stock_picking_delivery_package_type_domain/__manifest__.py new file mode 100644 index 0000000000..90bb1730f7 --- /dev/null +++ b/stock_picking_delivery_package_type_domain/__manifest__.py @@ -0,0 +1,19 @@ +# Copyright 2024 ACSONE SA/NV +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +{ + "name": "Stock Picking Delivery Package Type Domain", + "summary": """ + This module will allow to extend the domain to filter package type + selection in 'Choose Delivery Package' wizard""", + "version": "16.0.1.0.0", + "license": "AGPL-3", + "author": "ACSONE SA/NV,Odoo Community Association (OCA)", + "website": "https://github.com/OCA/delivery-carrier", + "depends": [ + "delivery", + ], + "data": [ + "wizards/choose_delivery_package.xml", + ], +} diff --git a/stock_picking_delivery_package_type_domain/readme/CONTEXT.md b/stock_picking_delivery_package_type_domain/readme/CONTEXT.md new file mode 100644 index 0000000000..a9f2bfd27c --- /dev/null +++ b/stock_picking_delivery_package_type_domain/readme/CONTEXT.md @@ -0,0 +1,7 @@ +In Odoo delivery module, you can choose the delivery package type if the carrier +is defined on the stock picking. + +The filtered package types displayed are based on the package type package_carrier_type +field. That domain is set on the view and is not extendable. + +This is why this module changed the domain in view to a computed field. diff --git a/stock_picking_delivery_package_type_domain/readme/CONTRIBUTORS.md b/stock_picking_delivery_package_type_domain/readme/CONTRIBUTORS.md new file mode 100644 index 0000000000..4e7e684726 --- /dev/null +++ b/stock_picking_delivery_package_type_domain/readme/CONTRIBUTORS.md @@ -0,0 +1 @@ +- Denis Roussel diff --git a/stock_picking_delivery_package_type_domain/readme/DESCRIPTION.md b/stock_picking_delivery_package_type_domain/readme/DESCRIPTION.md new file mode 100644 index 0000000000..96728282ad --- /dev/null +++ b/stock_picking_delivery_package_type_domain/readme/DESCRIPTION.md @@ -0,0 +1,4 @@ +This module allows to override the available package types during the put +in pack process related to a picking with a delivery carrier filled in. + +This module is a technical module, does nothing by its own and should be overriden. diff --git a/stock_picking_delivery_package_type_domain/static/description/icon.png b/stock_picking_delivery_package_type_domain/static/description/icon.png new file mode 100644 index 0000000000..3a0328b516 Binary files /dev/null and b/stock_picking_delivery_package_type_domain/static/description/icon.png differ diff --git a/stock_picking_delivery_package_type_domain/static/description/index.html b/stock_picking_delivery_package_type_domain/static/description/index.html new file mode 100644 index 0000000000..eac238717e --- /dev/null +++ b/stock_picking_delivery_package_type_domain/static/description/index.html @@ -0,0 +1,434 @@ + + + + + +Stock Picking Delivery Package Type Domain + + + +
+

Stock Picking Delivery Package Type Domain

+ + +

Beta License: AGPL-3 OCA/delivery-carrier Translate me on Weblate Try me on Runboat

+

This module allows to override the available package types during the +put in pack process related to a picking with a delivery carrier filled +in.

+

This module is a technical module, does nothing by its own and should be +overriden.

+

Table of contents

+ +
+

Use Cases / Context

+

In Odoo delivery module, you can choose the delivery package type if the +carrier is defined on the stock picking.

+

The filtered package types displayed are based on the package type +package_carrier_type field. That domain is set on the view and is not +extendable.

+

This is why this module changed the domain in view to a computed field.

+
+
+

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

+
    +
  • ACSONE SA/NV
  • +
+
+
+

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/delivery-carrier project on GitHub.

+

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

+
+
+
+ + diff --git a/stock_picking_delivery_package_type_domain/tests/__init__.py b/stock_picking_delivery_package_type_domain/tests/__init__.py new file mode 100644 index 0000000000..a9d51fbe27 --- /dev/null +++ b/stock_picking_delivery_package_type_domain/tests/__init__.py @@ -0,0 +1 @@ +from . import test_choose_delivery_package_type diff --git a/stock_picking_delivery_package_type_domain/tests/common.py b/stock_picking_delivery_package_type_domain/tests/common.py new file mode 100644 index 0000000000..a82ea9c7e0 --- /dev/null +++ b/stock_picking_delivery_package_type_domain/tests/common.py @@ -0,0 +1,82 @@ +# Copyright 2024 ACSONE SA/NV (https://www.acsone.eu) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). +from odoo_test_helper import FakeModelLoader + +from odoo.fields import Command + + +class CommonChooseDeliveryPackage: + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.loader = FakeModelLoader(cls.env, cls.__module__) + cls.loader.backup_registry() + + from .models.test import DeliveryCarrier, StockPackageType + + cls.loader.update_registry((DeliveryCarrier, StockPackageType)) + + cls.delivery_obj = cls.env["delivery.carrier"] + cls.package_type_obj = cls.env["stock.package.type"] + cls.package_type = cls.package_type_obj.create( + { + "name": "Type Test", + "package_carrier_type": "test", + } + ) + cls.product_delivery = cls.env["product.product"].create( + { + "name": "Delivery Product", + "type": "service", + } + ) + cls.delivery = cls.delivery_obj.create( + { + "name": "Test", + "delivery_type": "test", + "product_id": cls.product_delivery.id, + } + ) + cls.partner = cls.env["res.partner"].create( + { + "name": "Test Partner", + } + ) + + cls.product = cls.env["product.product"].create( + { + "name": "Test Product", + "type": "product", + } + ) + + cls.env["stock.quant"].with_context(inventory_mode=True).create( + { + "product_id": cls.product.id, + "location_id": cls.env.ref("stock.stock_location_stock").id, + "inventory_quantity": 10.0, + } + )._apply_inventory() + + @classmethod + def _create_sale(cls): + cls.sale = cls.env["sale.order"].create( + { + "partner_id": cls.partner.id, + "carrier_id": cls.delivery.id, + "order_line": [ + Command.create( + { + "product_id": cls.product.id, + "product_uom_qty": 5.0, + } + ) + ], + } + ) + return cls.sale + + @classmethod + def tearDownClass(cls): + cls.loader.restore_registry() + super().tearDownClass() diff --git a/stock_picking_delivery_package_type_domain/tests/models/test.py b/stock_picking_delivery_package_type_domain/tests/models/test.py new file mode 100644 index 0000000000..c804cd2982 --- /dev/null +++ b/stock_picking_delivery_package_type_domain/tests/models/test.py @@ -0,0 +1,19 @@ +from odoo import fields, models + + +class DeliveryCarrier(models.Model): + + _inherit = "delivery.carrier" + + delivery_type = fields.Selection( + selection_add=[("test", "Test")], ondelete={"test": "cascade"} + ) + + +class StockPackageType(models.Model): + + _inherit = "stock.package.type" + + package_carrier_type = fields.Selection( + selection_add=[("test", "test")], ondelete={"test": "cascade"} + ) diff --git a/stock_picking_delivery_package_type_domain/tests/test_choose_delivery_package_type.py b/stock_picking_delivery_package_type_domain/tests/test_choose_delivery_package_type.py new file mode 100644 index 0000000000..cd69fa297e --- /dev/null +++ b/stock_picking_delivery_package_type_domain/tests/test_choose_delivery_package_type.py @@ -0,0 +1,24 @@ +# Copyright 2024 ACSONE SA/NV (https://www.acsone.eu) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). +from odoo.addons.base.tests.common import BaseCommon + +from .common import CommonChooseDeliveryPackage + + +class TestChooseDeliveryPackageType(CommonChooseDeliveryPackage, BaseCommon): + def test_choose_delivery_package(self): + """ + Check the domain is still the standard one. + """ + sale = self._create_sale() + sale.action_confirm() + self.assertTrue(sale.picking_ids) + res = sale.picking_ids.action_put_in_pack() + model = res.get("res_model") + context = res.get("context") + self.assertEqual("choose.delivery.package", model) + self.wizard = self.env[model].with_context(**context).create({}) + self.assertTrue(self.wizard) + self.assertEqual( + [("package_carrier_type", "=", "test")], self.wizard.package_type_domain + ) diff --git a/stock_picking_delivery_package_type_domain/wizards/__init__.py b/stock_picking_delivery_package_type_domain/wizards/__init__.py new file mode 100644 index 0000000000..9925e2632c --- /dev/null +++ b/stock_picking_delivery_package_type_domain/wizards/__init__.py @@ -0,0 +1 @@ +from . import choose_delivery_package diff --git a/stock_picking_delivery_package_type_domain/wizards/choose_delivery_package.py b/stock_picking_delivery_package_type_domain/wizards/choose_delivery_package.py new file mode 100644 index 0000000000..e501914b37 --- /dev/null +++ b/stock_picking_delivery_package_type_domain/wizards/choose_delivery_package.py @@ -0,0 +1,23 @@ +# Copyright 2024 ACSONE SA/NV (https://www.acsone.eu) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). + +from odoo import api, fields, models + + +class ChooseDeliveryPackage(models.TransientModel): + + _inherit = "choose.delivery.package" + + package_type_domain = fields.Binary( + compute="_compute_package_type_domain", readonly=True + ) + + @api.depends_context("current_package_carrier_type") + @api.depends("picking_id") + def _compute_package_type_domain(self): + package_carrier_type = self.env.context.get( + "current_package_carrier_type", "none" + ) + domain = [("package_carrier_type", "=", package_carrier_type)] + for wizard in self: + wizard.package_type_domain = domain diff --git a/stock_picking_delivery_package_type_domain/wizards/choose_delivery_package.xml b/stock_picking_delivery_package_type_domain/wizards/choose_delivery_package.xml new file mode 100644 index 0000000000..0be609c0ff --- /dev/null +++ b/stock_picking_delivery_package_type_domain/wizards/choose_delivery_package.xml @@ -0,0 +1,18 @@ + + + + + choose.delivery.package.form + choose.delivery.package + + + + + + + package_type_domain + + + +