-
-
Notifications
You must be signed in to change notification settings - Fork 207
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[IMP] rma: custom route for replace action
This commit adds a new field, rma_out_replace_route_id, to the warehouse. If this field is set, it specifies a custom route to be used for RMA replacement actions, allowing separation of RMA replacement orders from regular deliveries. If the field is not set, the default delivery route will be used.
- Loading branch information
Showing
4 changed files
with
73 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
# Copyright 2023 Michael Tietz (MT Software) <[email protected]> | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
from odoo import Command | ||
from odoo.exceptions import UserError, ValidationError | ||
from odoo.tests import Form, TransactionCase, new_test_user, users | ||
from odoo.tools import mute_logger | ||
|
@@ -848,3 +849,67 @@ def test_autoconfirm_email(self): | |
) | ||
self.assertTrue(rma.name in mail_receipt.subject) | ||
self.assertTrue("products received" in mail_receipt.subject) | ||
|
||
def _test_receive_and_replace(self): | ||
rma = self._create_confirm_receive(self.partner, self.product, 10, self.rma_loc) | ||
delivery_form = Form( | ||
self.env["rma.delivery.wizard"].with_context( | ||
active_ids=rma.ids, | ||
rma_delivery_type="replace", | ||
) | ||
) | ||
delivery_form.product_id = rma.product_id | ||
delivery_form.product_uom_qty = 2 | ||
delivery_wizard = delivery_form.save() | ||
delivery_wizard.action_deliver() | ||
return rma | ||
|
||
def test_replace_picking_type(self): | ||
""" | ||
Test that by default, the replace operation uses the default delivery route, | ||
meaning the warehouse's default delivery picking type is applied. | ||
RMA replacement orders are not separated from regular deliveries, and both use | ||
the same picking type. | ||
""" | ||
rma = self._test_receive_and_replace() | ||
rma_in_type = self.warehouse.rma_in_type_id | ||
out_type = self.warehouse.out_type_id | ||
self.assertEqual(rma.reception_move_id.picking_type_id, rma_in_type) | ||
self.assertEqual(rma.delivery_move_ids.picking_type_id, out_type) | ||
|
||
def test_replace_picking_type_custom_picking_type(self): | ||
""" | ||
Test that when configured to use a custom route, the replace operation uses a | ||
custom picking type, separating RMA replacement orders from regular deliveries. | ||
The custom picking type is applied specifically for RMA replacements, instead | ||
of the default delivery picking type. | ||
""" | ||
rma_in_type = self.warehouse.rma_in_type_id | ||
rma_out_type = self.warehouse.rma_out_type_id | ||
route = self.env["stock.route"].create( | ||
{ | ||
"name": "RMA OUT replace", | ||
"active": True, | ||
"sequence": 100, | ||
"product_selectable": True, | ||
"rule_ids": [ | ||
Command.create( | ||
{ | ||
"name": "RMA OUT", | ||
"action": "pull", | ||
"picking_type_id": rma_out_type.id, | ||
"location_src_id": self.warehouse.lot_stock_id.id, | ||
"location_dest_id": self.env.ref( | ||
"stock.stock_location_customers" | ||
).id, | ||
}, | ||
) | ||
], | ||
} | ||
) | ||
self.warehouse.rma_out_replace_route_id = route | ||
rma = self._test_receive_and_replace() | ||
self.assertEqual(rma.reception_move_id.picking_type_id, rma_in_type) | ||
self.assertEqual(rma.delivery_move_ids.picking_type_id, rma_out_type) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters