[FIX]repair_refurbish. Set correct destination location in stock move lines

This commit is contained in:
ahenriquez
2019-09-12 13:33:18 +02:00
committed by Mateu Griful
parent c0a90ef4ac
commit 4bb1cfd300
2 changed files with 21 additions and 0 deletions

View File

@@ -14,3 +14,16 @@ class StockMove(models.Model):
vals['location_dest_id'] = self.env.context[ vals['location_dest_id'] = self.env.context[
'force_refurbish_location_dest_id'] 'force_refurbish_location_dest_id']
return super().create(vals_list) 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)

View File

@@ -84,8 +84,16 @@ class TestMrpMtoWithStock(TransactionCase):
if m.product_id == self.product: if m.product_id == self.product:
self.assertEqual(m.location_id, self.stock_location_stock) self.assertEqual(m.location_id, self.stock_location_stock)
self.assertEqual(m.location_dest_id, self.refurbish_loc) 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: elif m.product_id == self.refurbish_product:
self.assertEqual(m.location_id, self.refurbish_loc) self.assertEqual(m.location_id, self.refurbish_loc)
self.assertEqual(m.location_dest_id, self.customer_location) 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: else:
self.assertTrue(False, "Unexpected move.") self.assertTrue(False, "Unexpected move.")