[MOD] Fixed some problems when there are quants with diferente histories

This commit is contained in:
oihane
2015-03-03 13:38:58 +01:00
parent c3eb7f2a0f
commit c3718b9102
2 changed files with 16 additions and 5 deletions

View File

@@ -1,4 +1,14 @@
Quant merge
===========
This module allows to merge diferent quants if they meet some requirements.
This module allows to merge diferent quants if they meet some requirements.
Credits
=======
Contributors
------------
* Oihane Crucelaegui <oihanecrucelaegi@avanzosc.es>
* Pedro M. Baeza <pedro.baeza@serviciosbaeza.com>
* Ana Juaristi <ajuaristo@gmail.com>

View File

@@ -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