diff --git a/addons/sale/sale.py b/addons/sale/sale.py index 3bea2419718..02f6eb57188 100644 --- a/addons/sale/sale.py +++ b/addons/sale/sale.py @@ -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