Use purchase line unit when invoice line has no unit
Closes #12462 (grafted from 582bbe2add15d9d856b3a9315b8c8434f66b7248) --HG-- branch : 6.0
This commit is contained in:
1 parent
3d9ec296d9
commit
6104da65e7
1 file changed
+11
-9
@@ -1615,8 +1615,9 @@ class Line(sequence_ordered(), ModelSQL, ModelView):
|
||||
if invoice_line.type != 'line':
|
||||
continue
|
||||
if invoice_line not in skips:
|
||||
quantity += Uom.compute_qty(invoice_line.unit,
|
||||
invoice_line.quantity, self.unit)
|
||||
quantity += Uom.compute_qty(
|
||||
invoice_line.unit or self.unit, invoice_line.quantity,
|
||||
self.unit)
|
||||
return quantity
|
||||
|
||||
def _get_invoice_line_moves(self):
|
||||
@@ -1714,13 +1715,14 @@ class Line(sequence_ordered(), ModelSQL, ModelView):
|
||||
moved_quantity *= -1
|
||||
invoiced_quantity = 0
|
||||
for invoice_line in self.invoice_lines:
|
||||
if (
|
||||
(not invoice_line.invoice
|
||||
or invoice_line.invoice.state != 'cancelled')
|
||||
and self.unit and invoice_line.unit):
|
||||
invoiced_quantity += Uom.compute_qty(
|
||||
invoice_line.unit, invoice_line.quantity, self.unit,
|
||||
round=False)
|
||||
if (not invoice_line.invoice
|
||||
or invoice_line.invoice.state != 'cancelled'):
|
||||
if self.unit:
|
||||
invoiced_quantity += Uom.compute_qty(
|
||||
invoice_line.unit or self.unit, invoice_line.quantity,
|
||||
self.unit, round=False)
|
||||
else:
|
||||
invoiced_quantity += invoice_line.quantity
|
||||
actual_quantity = max(moved_quantity, invoiced_quantity, key=abs)
|
||||
if self.unit:
|
||||
actual_quantity = self.unit.round(actual_quantity)
|
||||
|
||||
Reference in new issue
Block a user