diff --git a/rma/tests/test_rma.py b/rma/tests/test_rma.py index 0ae4a9020..61a90eeea 100644 --- a/rma/tests/test_rma.py +++ b/rma/tests/test_rma.py @@ -3,6 +3,7 @@ from odoo.exceptions import UserError, ValidationError from odoo.tests import Form, common +from odoo.tools.safe_eval import safe_eval class TestRma(common.TransactionCase): @@ -129,11 +130,20 @@ def _deliver_rma(cls, rma_line_ids): ).create({}) wizard._create_picking() res = rma_line_ids.action_view_out_shipments() - picking = cls.env["stock.picking"].browse(res["res_id"]) - picking.action_assign() - for mv in picking.move_ids: - mv.quantity_done = mv.product_uom_qty - picking._action_done() + picking = cls.env["stock.picking"].browse() + if res["res_id"]: + picking = cls.env["stock.picking"].browse(res["res_id"]) + elif res.get("domain", False): + domain = res["domain"] + if isinstance(domain, str): + domain = safe_eval(domain) + picking = cls.env["stock.picking"].browse(domain[0][2]) + if picking: + for pick in picking: + pick.action_assign() + for mv in pick.move_ids: + mv.quantity_done = mv.product_uom_qty + pick._action_done() return picking @classmethod diff --git a/rma_sale/tests/test_rma_sale_tracking.py b/rma_sale/tests/test_rma_sale_tracking.py index b6c62788e..84dd709e4 100644 --- a/rma_sale/tests/test_rma_sale_tracking.py +++ b/rma_sale/tests/test_rma_sale_tracking.py @@ -81,7 +81,7 @@ def setUpClass(cls): picking.action_assign() - for move in picking.move_lines: + for move in picking.move_ids: if move.product_id.id == cls.product_serial_2.id: move.move_line_ids.write({"result_package_id": cls.package_2.id}) if move.product_id.id == cls.product_lot_2.id: @@ -145,7 +145,7 @@ def test_01_customer_rma_tracking(self): "Destination package should not be assigned", ) picking.action_assign() - for mv in picking.move_lines: + for mv in picking.move_ids: mv.quantity_done = mv.product_uom_qty picking._action_done() self.assertEqual(