@@ -14,6 +14,9 @@ def setUpClass(cls):
1414 cls .product = cls .env ["product.product" ].create (
1515 {"name" : "test_product" , "type" : "product" , "tracking" : "lot" }
1616 )
17+ cls .product2 = cls .env ["product.product" ].create (
18+ {"name" : "test_product 2" , "type" : "product" , "tracking" : "lot" }
19+ )
1720 cls .lot_1 = cls .env ["stock.lot" ].create (
1821 {"name" : "000001" , "product_id" : cls .product .id }
1922 )
@@ -101,3 +104,34 @@ def test_rma_form(self):
101104 self .assertEqual (rma_form .product_id , self .product )
102105 rma_form .product_id = self .env .ref ("product.product_product_4" )
103106 self .assertFalse (rma_form .lot_id )
107+
108+ def test_different_return_product (self ):
109+ """if the return product is different than the rma product, the lot can't be set
110+ on the reception move neither on the rma"""
111+ self .operation .different_return_product = True
112+ stock_return_picking_form = Form (
113+ self .env ["stock.return.picking" ].with_context (
114+ active_ids = self .picking .ids ,
115+ active_id = self .picking .id ,
116+ active_model = "stock.picking" ,
117+ )
118+ )
119+ stock_return_picking_form .create_rma = True
120+ stock_return_picking_form .rma_operation_id = self .operation
121+ with self .assertRaises (
122+ AssertionError , msg = "return_product_id is a required field"
123+ ):
124+ stock_return_picking_form .save ()
125+ with stock_return_picking_form .product_return_moves .edit (0 ) as return_line :
126+ return_line .return_product_id = self .product2
127+ with stock_return_picking_form .product_return_moves .edit (1 ) as return_line :
128+ return_line .return_product_id = self .product2
129+ return_wizard = stock_return_picking_form .save ()
130+ self .assertEqual (len (return_wizard .product_return_moves ), 2 )
131+ return_wizard .create_returns ()
132+ self .assertEqual (self .picking .rma_count , 2 )
133+ rmas = self .picking .move_ids .rma_ids
134+ self .assertTrue (rmas .exists ())
135+ self .assertTrue (rmas .reception_move_id .exists ())
136+ self .assertFalse (rmas .lot_id )
137+ self .assertFalse (rmas .reception_move_id .restrict_lot_id )
0 commit comments