[FIX] sale: Invoicing several SO with same partner and different invoice address

When invoicing several SO with same partner and with different invoice address,
different invoices have to be created with each invoice address.

Used case:

-create a customer with two invoice addresses
-create a SO for this customer with the first address
-create a SO for this customer with the second address
-select the two SO in the SO tree view
-click on "Invoice Order"
-click on "Create and view invoices"

Results:

Before the fix: The two SO are merged in one invoice with the second
address.

After the fix: Two invoices are created, one for the first address and
one for the second address.

opw:675961
This commit is contained in:
Goffin Simon
2016-04-28 09:15:16 +02:00
parent 6c9d92d783
commit 93aed40105
+2 -2
View File
@@ -293,7 +293,7 @@ class SaleOrder(models.Model):
"""
Create the invoice associated to the SO.
:param grouped: if True, invoices are grouped by SO id. If False, invoices are grouped by
(partner, currency)
(partner_invoice_id, currency)
:param final: if True, refunds will be generated if necessary
:returns: list of created invoices
"""
@@ -302,7 +302,7 @@ class SaleOrder(models.Model):
invoices = {}
for order in self:
group_key = order.id if grouped else (order.partner_id.id, order.currency_id.id)
group_key = order.id if grouped else (order.partner_invoice_id.id, order.currency_id.id)
for line in order.order_line.sorted(key=lambda l: l.qty_to_invoice < 0):
if float_is_zero(line.qty_to_invoice, precision_digits=precision):
continue