Fix COGS computation with negative quantity

issue3287
review976002
(transplanted from b041a5be1444d626bd9105f28f6861c7695ffaa9)
This commit is contained in:
Cédric Krier committed 2013-07-22 14:27:21 +02:00
1 parent 8e97c7b779
commit fb1dc57e4e
1 file changed
+8 -1
+8 -1
View File
@@ -81,10 +81,17 @@ class InvoiceLine:
type_ = 'out_supplier'
elif self.invoice.type == 'out_credit_note':
type_ = 'in_customer'
if self.quantity < 0:
direction, target = type_.split('_')
if direction == 'in':
direction = 'out'
else:
direction = 'in'
type_ = '%s_%s' % (direction, target)
moves.sort(key=operator.attrgetter('effective_date'))
cost = Move.update_anglo_saxon_quantity_product_cost(
self.product, moves, self.quantity, self.unit, type_)
self.product, moves, abs(self.quantity), self.unit, type_)
cost = self.invoice.currency.round(cost)
anglo_saxon_move_lines = self._get_anglo_saxon_move_lines(cost, type_)