From 1bb2ed9623ba8c50c6ce36d8101acba8ffddcd83 Mon Sep 17 00:00:00 2001 From: IEL Date: Tue, 13 Oct 2020 08:12:30 +0000 Subject: [PATCH] [FIX] website_sale_digital: allow download without reconciliation TLDR: after installation accounting app, invoices paid online get status "In Payment" until reconciliation; this commit allows to download digital content without waiting reconciliation which may take days or week Steps: * Install Accounting app * Install website_sale_digital * Create Digital product (Product Type: Service + use Digital Files smart button to upload a file) * Setup payment acquirer (e.g. Paypal) * Buy digital product online and pay * Open the Sale Order in Portal Before: * No "Downloads" button near to product name After * User can download files after purchasing Notes * In Odoo 13.0 it worked via "post_at" option, which is removed in Odoo 14. See https://github.com/odoo/odoo/commit/caeb782841fc5a7ad71a196e2c9ee67644ef9074: > - Remove the post_at bank reconciliation feature. The "paid" state will be set on the invoices only if reconciled with a journal entry involving the journal's liquidity account. > With invoicing, the payment will do that so the "in_payment" state should never be shown up. > With accounting, only the statement lines have the power to move an invoice to the "paid" state. --- opw-2353064 closes odoo/odoo#59959 X-original-commit: 103abd3284cea1723adc0e4b90e57961a4fac2a0 Signed-off-by: Nicolas Martinelli (nim) --- addons/website_sale_digital/controllers/main.py | 2 +- addons/website_sale_digital/models/account_invoice.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/website_sale_digital/controllers/main.py b/addons/website_sale_digital/controllers/main.py index f3899b92e10..cac2a1de061 100644 --- a/addons/website_sale_digital/controllers/main.py +++ b/addons/website_sale_digital/controllers/main.py @@ -36,7 +36,7 @@ class WebsiteSaleDigital(CustomerPortal): if not 'sale_order' in response.qcontext: return response order = response.qcontext['sale_order'] - invoiced_lines = request.env['account.move.line'].sudo().search([('move_id', 'in', order.invoice_ids.ids), ('move_id.payment_state', '=', 'paid')]) + invoiced_lines = request.env['account.move.line'].sudo().search([('move_id', 'in', order.invoice_ids.ids), ('move_id.payment_state', 'in', ['paid', 'in_payment'])]) products = invoiced_lines.mapped('product_id') | order.order_line.filtered(lambda r: not r.price_subtotal).mapped('product_id') if not order.amount_total: # in that case, we should add all download links to the products diff --git a/addons/website_sale_digital/models/account_invoice.py b/addons/website_sale_digital/models/account_invoice.py index bc0fc0636c9..c9c26c9e8fe 100644 --- a/addons/website_sale_digital/models/account_invoice.py +++ b/addons/website_sale_digital/models/account_invoice.py @@ -14,7 +14,7 @@ class AccountInvoiceLine(models.Model): # Get paid invoices purchases = self.sudo().search_read( domain=[ - ('move_id.payment_state', '=', 'paid'), + ('move_id.payment_state', 'in', ['paid', 'in_payment']), ('move_id.partner_id', '=', partner.id), ('product_id', '!=', False), ],