Use sale line unit when invoice line has no unit
Closes #12462 (grafted from 2190acdc50ef3ba11c02847b0ee853d2e9c04179) --HG-- branch : 6.0
This commit is contained in:
+14
-11
@@ -1567,8 +1567,9 @@ class SaleLine(TaxableMixin, 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):
|
||||
@@ -1642,8 +1643,9 @@ class SaleLine(TaxableMixin, sequence_ordered(), ModelSQL, ModelView):
|
||||
for invoice_line in self.invoice_lines:
|
||||
if (invoice_line.invoice
|
||||
and invoice_line.invoice.state == 'paid'):
|
||||
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_shipped_quantity(self, shipment_type):
|
||||
@@ -1687,13 +1689,14 @@ class SaleLine(TaxableMixin, 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