-
-
Notifications
You must be signed in to change notification settings - Fork 204
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[IMP] rma_sale: Display the allowed quantity to return in the RMA wizard
- Display the allowed quantity to return - Simplify data encoding by adding a button to select/deselect all lines - Ensure that the quantity to return is always less than or equal to the allowed quantity
- Loading branch information
Showing
10 changed files
with
158 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -106,6 +106,8 @@ Contributors | |
|
||
* Chafique Delli <[email protected]> | ||
* Giovanni Serra - Ooops <[email protected]> | ||
* Souheil Bejaoui - ACSONE SA/NV <[email protected]> | ||
* Jacques-Etienne Baudoux - BCIM <[email protected]> | ||
|
||
Maintainers | ||
~~~~~~~~~~~ | ||
|
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 |
---|---|---|
|
@@ -7,3 +7,5 @@ | |
|
||
* Chafique Delli <[email protected]> | ||
* Giovanni Serra - Ooops <[email protected]> | ||
* Souheil Bejaoui - ACSONE SA/NV <[email protected]> | ||
* Jacques-Etienne Baudoux - BCIM <[email protected]> |
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,3 +2,4 @@ | |
|
||
from . import test_rma_sale | ||
from . import test_rma_sale_portal | ||
from . import test_rma_sale_allowed_qty |
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 |
---|---|---|
@@ -0,0 +1,110 @@ | ||
# Copyright 2024 ACSONE SA/NV | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
from odoo import Command | ||
from odoo.exceptions import ValidationError | ||
from odoo.tests.common import TransactionCase | ||
|
||
|
||
class TestRmaSaleQuantityAllowed(TransactionCase): | ||
@classmethod | ||
def setUpClass(cls): | ||
super().setUpClass() | ||
cls.warehouse = cls.env.ref("stock.warehouse0") | ||
cls.loc_stock = cls.warehouse.lot_stock_id | ||
cls.partner1 = cls.env["res.partner"].create({"name": "Partner"}) | ||
cls.p1 = cls.env["product.product"].create( | ||
{"name": "Unittest P1", "type": "product"} | ||
) | ||
cls.so = cls.env["sale.order"].create( | ||
{ | ||
"partner_id": cls.partner1.id, | ||
"order_line": [ | ||
Command.create( | ||
{ | ||
"name": cls.p1.name, | ||
"product_id": cls.p1.id, | ||
"product_uom_qty": 5, | ||
"price_unit": 50, | ||
}, | ||
) | ||
], | ||
} | ||
) | ||
cls.env["stock.quant"].with_context(inventory_mode=True).create( | ||
{ | ||
"product_id": cls.p1.id, | ||
"inventory_quantity": 10, | ||
"location_id": cls.loc_stock.id, | ||
} | ||
)._apply_inventory() | ||
cls.so.action_confirm() | ||
cls.picking = cls.so.picking_ids[0] | ||
|
||
def _get_rma_wizard(self): | ||
action = self.so.action_create_rma() | ||
return self.env[action.get("res_model")].browse(action.get("res_id")) | ||
|
||
def _deliver(self, qty): | ||
self.picking.move_line_ids.qty_done = qty | ||
self.picking._action_done() | ||
self.assertEqual(self.picking.state, "done") | ||
self.assertEqual(self.so.order_line.qty_delivered, qty) | ||
|
||
def test_1(self): | ||
""" | ||
Test rma wizard: | ||
- fully deliver the so | ||
- open rma wizard | ||
expected: | ||
- qty proposed: 5 | ||
- allowed qty 5 | ||
- qty 0 if is_return_all = False | ||
""" | ||
self._deliver(5) | ||
wizard = self._get_rma_wizard() | ||
self.assertEqual(len(wizard.line_ids), 1) | ||
self.assertEqual(wizard.line_ids.quantity, 5) | ||
self.assertEqual(wizard.line_ids.allowed_quantity, 5) | ||
wizard.is_return_all = False | ||
self.assertEqual(wizard.line_ids.quantity, 0) | ||
wizard.is_return_all = True | ||
self.assertEqual(wizard.line_ids.quantity, 5) | ||
|
||
def test_2(self): | ||
""" | ||
Test rma wizard: | ||
- partially deliver the so | ||
- open rma wizard | ||
expected: | ||
- qty proposed: 3 | ||
- allowed qty 3 | ||
- qty 0 if is_return_all = False | ||
""" | ||
self._deliver(3) | ||
wizard = self._get_rma_wizard() | ||
self.assertEqual(len(wizard.line_ids), 1) | ||
self.assertEqual(wizard.line_ids.quantity, 3) | ||
self.assertEqual(wizard.line_ids.allowed_quantity, 3) | ||
wizard.is_return_all = False | ||
self.assertEqual(wizard.line_ids.quantity, 0) | ||
wizard.is_return_all = True | ||
self.assertEqual(wizard.line_ids.quantity, 3) | ||
|
||
def test_3(self): | ||
""" | ||
Test rma wizard: | ||
Try to return more than the allowed qty | ||
""" | ||
self._deliver(3) | ||
wizard = self._get_rma_wizard() | ||
self.assertEqual(len(wizard.line_ids), 1) | ||
self.assertEqual(wizard.line_ids.quantity, 3) | ||
self.assertEqual(wizard.line_ids.allowed_quantity, 3) | ||
with self.assertRaises( | ||
ValidationError, msg="You can't exceed the allowed quantity" | ||
): | ||
wizard.line_ids.quantity = 5 | ||
wizard.line_ids.quantity = 1 |
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