From 3d46887d38e970f4932cef1bd4a887f6629151fe Mon Sep 17 00:00:00 2001 From: Kirti Choudhary Date: Tue, 19 Jun 2018 17:16:29 +0530 Subject: [PATCH] [IMP] sale: Change the default invoicing method if there are downpayments Purpose ======= Currently the default invoicing method is not very clear. Specification ============= Currently the result is not really correct. We can propose to deduct the down payment even if there are no down payments on the sales order. Now the option to deduct down payments will be selected if there is a downpayment line on the sales order and if there exists at least one invoice linked to the sales order that is not cancelled. Task ID : 33126 --- addons/sale/wizard/sale_make_invoice_advance.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/addons/sale/wizard/sale_make_invoice_advance.py b/addons/sale/wizard/sale_make_invoice_advance.py index 69c09932b66..c7187e816c0 100644 --- a/addons/sale/wizard/sale_make_invoice_advance.py +++ b/addons/sale/wizard/sale_make_invoice_advance.py @@ -21,11 +21,11 @@ class SaleAdvancePaymentInv(models.TransientModel): if self._count() == 1: sale_obj = self.env['sale.order'] order = sale_obj.browse(self._context.get('active_ids'))[0] - if all([line.product_id.invoice_policy == 'order' for line in order.order_line]) or order.invoice_count: + if order.order_line.filtered(lambda dp: dp.is_downpayment) and order.invoice_ids.filtered(lambda invoice: invoice.state != 'cancel'): return 'all' - else: - return 'all' - return 'delivered' + else: + return 'delivered' + return 'all' @api.model def _default_product_id(self):