diff --git a/addons/sale/wizard/sale_make_invoice_advance.py b/addons/sale/wizard/sale_make_invoice_advance.py index 0656143df1e..7dc24060f5f 100644 --- a/addons/sale/wizard/sale_make_invoice_advance.py +++ b/addons/sale/wizard/sale_make_invoice_advance.py @@ -69,6 +69,9 @@ class SaleAdvancePaymentInv(models.TransientModel): domain=[('type_tax_use', '=', 'sale')], help="Taxes used for deposits") + # UI + display_draft_invoice_warning = fields.Boolean(compute="_compute_display_draft_invoice_warning") + #=== COMPUTE METHODS ===# @api.depends('sale_order_ids') @@ -106,6 +109,14 @@ class SaleAdvancePaymentInv(models.TransientModel): if wizard.count == 1: wizard.product_id = wizard.company_id.sale_down_payment_product_id + @api.depends('sale_order_ids', 'advance_payment_method', 'deduct_down_payments') + def _compute_display_draft_invoice_warning(self): + for wizard in self: + wizard.display_draft_invoice_warning = ( + wizard.advance_payment_method == 'delivered' and + any(aml.parent_state == 'draft' for aml in wizard.sale_order_ids.order_line.invoice_lines) + ) + #=== ONCHANGE METHODS ===# @api.onchange('advance_payment_method') diff --git a/addons/sale/wizard/sale_make_invoice_advance_views.xml b/addons/sale/wizard/sale_make_invoice_advance_views.xml index 48a58c4742e..afaf09f4d51 100644 --- a/addons/sale/wizard/sale_make_invoice_advance_views.xml +++ b/addons/sale/wizard/sale_make_invoice_advance_views.xml @@ -10,6 +10,10 @@ Invoices will be created in draft so that you can review them before validation.
++ The new invoice will deduct draft invoices linked to this sale order. +