[IMP] rma: Refactor all rma modules in order to consider using the correct price unit in moves

Otherwise the inventory accounting will be completely wrong.
This commit is contained in:
Jordi Ballester
2022-03-02 11:35:08 +01:00
committed by Carlos Vallés Fuster
parent d6960ba8b7
commit 8bedb814cf

View File

@@ -35,7 +35,8 @@ class StockRule(models.Model):
res["partner_id"] = line.delivery_address_id.id res["partner_id"] = line.delivery_address_id.id
else: else:
res["partner_id"] = line.rma_id.partner_id.id res["partner_id"] = line.rma_id.partner_id.id
dest_loc = self.env["stock.location"].browse([res["location_dest_id"]])[0] company_id = res["company_id"]
if dest_loc.usage == "internal": company = self.env["res.company"].browse(company_id)
res["price_unit"] = line.price_unit cost = product_id.with_company(company).standard_price
res["price_unit"] = cost
return res return res