[repair_refurbish][fix] Change destination location

This commit is contained in:
Jordi Ballester
2021-10-08 17:15:14 +02:00
parent d60cf789f4
commit a502c723bb
2 changed files with 14 additions and 3 deletions

View File

@@ -103,8 +103,16 @@ class RepairLine(models.Model):
and "to_refurbish" in context
and not context["to_refurbish"]
):
scrap_location_id = self.env["stock.location"].search(
[("usage", "=", "customer")], limit=1
scrap_location_id = (
self.env["stock.location"]
.search(
[
("scrap_location", "=", True),
("company_id", "in", [self.repair_id.company_id.id, False]),
],
limit=1,
)
.id
)
self.location_dest_id = scrap_location_id
return res

View File

@@ -14,6 +14,9 @@ class TestMrpMtoWithStock(TransactionCase):
self.stock_location_stock = self.env.ref("stock.stock_location_stock")
self.customer_location = self.env.ref("stock.stock_location_customers")
self.scrap_location = self.env["stock.location"].search(
[("scrap_location", "=", True)], limit=1
)
self.refurbish_loc = self.env.ref("repair_refurbish.stock_location_refurbish")
self.refurbish_product = self.product_obj.create(
@@ -159,4 +162,4 @@ class TestMrpMtoWithStock(TransactionCase):
move = self.move_obj.search(
[("product_id", "=", self.material2.id)], order="create_date desc", limit=1
)[0]
self.assertEqual(move.location_dest_id, self.customer_location)
self.assertEqual(move.location_dest_id, self.scrap_location)