From c3718b9102847ee17b7c7a2f000c2a132c7f9bfb Mon Sep 17 00:00:00 2001 From: oihane Date: Tue, 3 Mar 2015 13:38:58 +0100 Subject: [PATCH] [MOD] Fixed some problems when there are quants with diferente histories --- README.rst | 12 +++++++++++- models/stock.py | 9 +++++---- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/README.rst b/README.rst index 56450f78e..bacfede3a 100644 --- a/README.rst +++ b/README.rst @@ -1,4 +1,14 @@ Quant merge =========== -This module allows to merge diferent quants if they meet some requirements. \ No newline at end of file +This module allows to merge diferent quants if they meet some requirements. + + +Credits +======= + +Contributors +------------ +* Oihane Crucelaegui +* Pedro M. Baeza +* Ana Juaristi \ No newline at end of file diff --git a/models/stock.py b/models/stock.py index c269edcb5..8e627413c 100644 --- a/models/stock.py +++ b/models/stock.py @@ -19,12 +19,13 @@ class StockQuant(models.Model): ('package_id', '=', self.package_id.id), ('location_id', '=', self.location_id.id), ('reservation_id', '=', False), - ('propagated_from_id', '=', False)]) + ('propagated_from_id', '=', self.propagated_from_id.id)]) qty = cost = 0 for quant in quants: - qty += quant.qty - cost += quant.cost - quant.unlink() + if self._get_latest_move(self) == self._get_latest_move(quant): + qty += quant.qty + cost += quant.cost + quant.unlink() self.cost += cost self.qty += qty