From 6f4dbc4303eda1800b6669cf95c5febd6b78694f Mon Sep 17 00:00:00 2001 From: ahenriquez Date: Thu, 12 Sep 2019 13:33:18 +0200 Subject: [PATCH] [FIX]repair_refurbish. Set correct destination location in stock move lines --- repair_refurbish/models/stock_move.py | 13 +++++++++++++ repair_refurbish/tests/test_repair_refurbish.py | 8 ++++++++ 2 files changed, 21 insertions(+) diff --git a/repair_refurbish/models/stock_move.py b/repair_refurbish/models/stock_move.py index 024b76f8d..d6ae6bda3 100644 --- a/repair_refurbish/models/stock_move.py +++ b/repair_refurbish/models/stock_move.py @@ -14,3 +14,16 @@ class StockMove(models.Model): vals['location_dest_id'] = self.env.context[ 'force_refurbish_location_dest_id'] return super().create(vals_list) + + +class StockMoveLine(models.Model): + + _inherit = 'stock.move.line' + + @api.model_create_multi + def create(self, vals_list): + if 'force_refurbish_location_dest_id' in self.env.context: + for vals in vals_list: + vals['location_dest_id'] = self.env.context[ + 'force_refurbish_location_dest_id'] + return super().create(vals_list) diff --git a/repair_refurbish/tests/test_repair_refurbish.py b/repair_refurbish/tests/test_repair_refurbish.py index 28bfba265..7525ffb68 100644 --- a/repair_refurbish/tests/test_repair_refurbish.py +++ b/repair_refurbish/tests/test_repair_refurbish.py @@ -84,8 +84,16 @@ class TestMrpMtoWithStock(TransactionCase): if m.product_id == self.product: self.assertEqual(m.location_id, self.stock_location_stock) self.assertEqual(m.location_dest_id, self.refurbish_loc) + self.assertEqual(m.mapped('move_line_ids.location_id'), + self.stock_location_stock) + self.assertEqual(m.mapped('move_line_ids.location_dest_id'), + self.refurbish_loc) elif m.product_id == self.refurbish_product: self.assertEqual(m.location_id, self.refurbish_loc) self.assertEqual(m.location_dest_id, self.customer_location) + self.assertEqual(m.mapped('move_line_ids.location_id'), + self.refurbish_loc) + self.assertEqual(m.mapped('move_line_ids.location_dest_id'), + self.customer_location) else: self.assertTrue(False, "Unexpected move.")