diff --git a/rma_sale_stock_picking_group_by_partner_by_carrier/README.rst b/rma_sale_stock_picking_group_by_partner_by_carrier/README.rst new file mode 100644 index 000000000..12bb6e5d2 --- /dev/null +++ b/rma_sale_stock_picking_group_by_partner_by_carrier/README.rst @@ -0,0 +1,94 @@ +================================================== +RMA Sale Stock Picking Group By Partner By Carrier +================================================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:5b15b6fe815b67e8c48bcf227379738fc6fa7d0f8e9fd78469bc3a58ce02a073 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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%2Frma-lightgray.png?logo=github + :target: https://github.com/OCA/rma/tree/18.0/rma_sale_stock_picking_group_by_partner_by_carrier + :alt: OCA/rma +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/rma-18-0/rma-18-0-rma_sale_stock_picking_group_by_partner_by_carrier + :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/rma&target_branch=18.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +When ``stock_picking_group_by_partner_by_carrier`` is installed, sale +order pickings are linked via a ``Many2many`` field (``sale_ids``) on +the procurement group instead of the standard ``Many2one`` +(``sale_id``). + +The ``rma_sale`` module only populates ``sale_id`` when creating the RMA +procurement group. As a result, RMA return pickings become invisible +from the sale order's "Deliveries" button. + +This glue module bridges ``sale_id`` → ``sale_ids`` on the procurement +group so that RMA return pickings remain visible from the sale order. + +**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 +------- + +* ACSONE SA/NV + +Contributors +------------ + +- Souheil Bejaoui - ACSONE SA/NV souheil.bejaoui@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. + +.. |maintainer-sbejaoui| image:: https://github.com/sbejaoui.png?size=40px + :target: https://github.com/sbejaoui + :alt: sbejaoui + +Current `maintainer `__: + +|maintainer-sbejaoui| + +This module is part of the `OCA/rma `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/rma_sale_stock_picking_group_by_partner_by_carrier/__init__.py b/rma_sale_stock_picking_group_by_partner_by_carrier/__init__.py new file mode 100644 index 000000000..0650744f6 --- /dev/null +++ b/rma_sale_stock_picking_group_by_partner_by_carrier/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/rma_sale_stock_picking_group_by_partner_by_carrier/__manifest__.py b/rma_sale_stock_picking_group_by_partner_by_carrier/__manifest__.py new file mode 100644 index 000000000..f413e9072 --- /dev/null +++ b/rma_sale_stock_picking_group_by_partner_by_carrier/__manifest__.py @@ -0,0 +1,19 @@ +# Copyright 2025 ACSONE SA/NV +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +{ + "name": "RMA Sale Stock Picking Group By Partner By Carrier", + "summary": "Bridge RMA sale procurement groups with grouped pickings", + "version": "18.0.1.0.0", + "development_status": "Beta", + "category": "RMA", + "website": "https://github.com/OCA/rma", + "author": "ACSONE SA/NV, Odoo Community Association (OCA)", + "maintainers": ["sbejaoui"], + "license": "AGPL-3", + "installable": True, + "auto_install": True, + "depends": [ + "rma_sale", + "stock_picking_group_by_partner_by_carrier", + ], +} diff --git a/rma_sale_stock_picking_group_by_partner_by_carrier/models/__init__.py b/rma_sale_stock_picking_group_by_partner_by_carrier/models/__init__.py new file mode 100644 index 000000000..0031f431f --- /dev/null +++ b/rma_sale_stock_picking_group_by_partner_by_carrier/models/__init__.py @@ -0,0 +1 @@ +from . import rma diff --git a/rma_sale_stock_picking_group_by_partner_by_carrier/models/rma.py b/rma_sale_stock_picking_group_by_partner_by_carrier/models/rma.py new file mode 100644 index 000000000..9efa76ee4 --- /dev/null +++ b/rma_sale_stock_picking_group_by_partner_by_carrier/models/rma.py @@ -0,0 +1,24 @@ +# Copyright 2025 ACSONE SA/NV +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import Command, models + + +class Rma(models.Model): + _inherit = "rma" + + def _prepare_procurement_group_vals(self): + # Bridge sale_id (M2O) → sale_ids (M2M) on the procurement group. + # stock_picking_group_by_partner_by_carrier computes + # stock.picking.sale_ids from move_ids.group_id.sale_ids (M2M), + # but rma_sale only sets sale_id (M2O). Without this bridge, + # RMA return pickings are invisible from the SO "Deliveries" button. + vals = super()._prepare_procurement_group_vals() + sale_id = vals.get("sale_id") + sale_ids = vals.get("sale_ids") + if sale_id: + if sale_ids: + sale_ids.append(Command.link(sale_id)) + else: + vals["sale_ids"] = [Command.link(sale_id)] + return vals diff --git a/rma_sale_stock_picking_group_by_partner_by_carrier/pyproject.toml b/rma_sale_stock_picking_group_by_partner_by_carrier/pyproject.toml new file mode 100644 index 000000000..4231d0ccc --- /dev/null +++ b/rma_sale_stock_picking_group_by_partner_by_carrier/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/rma_sale_stock_picking_group_by_partner_by_carrier/readme/CONTRIBUTORS.md b/rma_sale_stock_picking_group_by_partner_by_carrier/readme/CONTRIBUTORS.md new file mode 100644 index 000000000..80fec2f67 --- /dev/null +++ b/rma_sale_stock_picking_group_by_partner_by_carrier/readme/CONTRIBUTORS.md @@ -0,0 +1 @@ +- Souheil Bejaoui - ACSONE SA/NV diff --git a/rma_sale_stock_picking_group_by_partner_by_carrier/readme/DESCRIPTION.md b/rma_sale_stock_picking_group_by_partner_by_carrier/readme/DESCRIPTION.md new file mode 100644 index 000000000..c272c2246 --- /dev/null +++ b/rma_sale_stock_picking_group_by_partner_by_carrier/readme/DESCRIPTION.md @@ -0,0 +1,10 @@ +When ``stock_picking_group_by_partner_by_carrier`` is installed, sale order +pickings are linked via a ``Many2many`` field (``sale_ids``) on the procurement +group instead of the standard ``Many2one`` (``sale_id``). + +The ``rma_sale`` module only populates ``sale_id`` when creating the RMA +procurement group. As a result, RMA return pickings become invisible from the +sale order's "Deliveries" button. + +This glue module bridges ``sale_id`` → ``sale_ids`` on the procurement group so +that RMA return pickings remain visible from the sale order. diff --git a/rma_sale_stock_picking_group_by_partner_by_carrier/static/description/icon.png b/rma_sale_stock_picking_group_by_partner_by_carrier/static/description/icon.png new file mode 100644 index 000000000..3a0328b51 Binary files /dev/null and b/rma_sale_stock_picking_group_by_partner_by_carrier/static/description/icon.png differ diff --git a/rma_sale_stock_picking_group_by_partner_by_carrier/static/description/index.html b/rma_sale_stock_picking_group_by_partner_by_carrier/static/description/index.html new file mode 100644 index 000000000..a69912f9e --- /dev/null +++ b/rma_sale_stock_picking_group_by_partner_by_carrier/static/description/index.html @@ -0,0 +1,433 @@ + + + + + +RMA Sale Stock Picking Group By Partner By Carrier + + + +
+

RMA Sale Stock Picking Group By Partner By Carrier

+ + +

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

+

When stock_picking_group_by_partner_by_carrier is installed, sale +order pickings are linked via a Many2many field (sale_ids) on +the procurement group instead of the standard Many2one +(sale_id).

+

The rma_sale module only populates sale_id when creating the RMA +procurement group. As a result, RMA return pickings become invisible +from the sale order’s “Deliveries” button.

+

This glue module bridges sale_idsale_ids on the procurement +group so that RMA return pickings remain visible from the sale order.

+

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

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

+

Current maintainer:

+

sbejaoui

+

This module is part of the OCA/rma project on GitHub.

+

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

+
+
+
+ + diff --git a/rma_sale_stock_picking_group_by_partner_by_carrier/tests/__init__.py b/rma_sale_stock_picking_group_by_partner_by_carrier/tests/__init__.py new file mode 100644 index 000000000..dd5a38605 --- /dev/null +++ b/rma_sale_stock_picking_group_by_partner_by_carrier/tests/__init__.py @@ -0,0 +1 @@ +from . import test_rma_sale_picking_group diff --git a/rma_sale_stock_picking_group_by_partner_by_carrier/tests/test_rma_sale_picking_group.py b/rma_sale_stock_picking_group_by_partner_by_carrier/tests/test_rma_sale_picking_group.py new file mode 100644 index 000000000..5164d6cd3 --- /dev/null +++ b/rma_sale_stock_picking_group_by_partner_by_carrier/tests/test_rma_sale_picking_group.py @@ -0,0 +1,87 @@ +# Copyright 2025 ACSONE SA/NV +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo.tests import tagged + +from odoo.addons.rma_sale.tests.test_rma_sale import TestRmaSaleBase + + +@tagged("post_install", "-at_install") +class TestRmaSalePickingGroup(TestRmaSaleBase): + """Test that RMA return pickings are visible from the SO.""" + + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.rma_operation = cls.env["rma.operation"].create( + { + "name": "Test Return (picking group)", + "action_create_receipt": "automatic_on_confirm", + "action_create_delivery": "manual_after_receipt", + "action_create_refund": False, + } + ) + + @classmethod + def _create_confirmed_and_delivered_sale(cls): + order = cls._create_sale_order([(cls.product_1, 1)]) + order.action_confirm() + for picking in order.picking_ids: + picking.action_assign() + for move in picking.move_ids: + move.quantity = move.product_uom_qty + picking.button_validate() + return order + + def test_procurement_group_has_sale_ids(self): + """RMA procurement group must have sale_ids (M2M) populated.""" + order = self._create_confirmed_and_delivered_sale() + delivery_move = order.picking_ids.move_ids.filtered( + lambda move: move.state == "done" + )[:1] + rma = self.env["rma"].create( + { + "partner_id": order.partner_id.id, + "order_id": order.id, + "product_id": self.product_1.id, + "product_uom_qty": 1, + "operation_id": self.rma_operation.id, + "location_id": self.wh.rma_loc_id.id, + "move_id": delivery_move.id, + "picking_id": delivery_move.picking_id.id, + } + ) + rma.action_confirm() + group = rma.procurement_group_id + self.assertIn( + order, + group.sale_ids, + "Procurement group must include the SO in sale_ids (M2M)", + ) + + def test_rma_return_picking_visible_from_sale_order(self): + """RMA return picking must appear in sale.order.picking_ids.""" + order = self._create_confirmed_and_delivered_sale() + delivery_move = order.picking_ids.move_ids.filtered( + lambda move: move.state == "done" + )[:1] + rma = self.env["rma"].create( + { + "partner_id": order.partner_id.id, + "order_id": order.id, + "product_id": self.product_1.id, + "product_uom_qty": 1, + "operation_id": self.rma_operation.id, + "location_id": self.wh.rma_loc_id.id, + "move_id": delivery_move.id, + "picking_id": delivery_move.picking_id.id, + } + ) + rma.action_confirm() + reception_picking = rma.reception_move_id.picking_id + self.assertTrue(reception_picking) + self.assertIn( + reception_picking, + order.picking_ids, + "RMA return picking must be visible from the SO 'Deliveries' button", + )