From abdae3865615f355e1efedfd3ee8737ecfe073eb Mon Sep 17 00:00:00 2001 From: MerlinGuillaume Date: Fri, 26 May 2023 14:50:50 +0000 Subject: [PATCH] [FIX] account: group by payment status in the invoice analysis An error is thrown when displaying the invoice analysis with a group by on payment status when there is at least one invoice partially paid Steps to reproduce: 1. Install Invoicing 2. Open Invoicing and partially pay any invoice 3. Go to Invoicing > Reporting > Invoice Analysis 4. Group by custom field: payment status Solution: Use all the possible payment_state values of account_move for account_invoice_report opw-3213576 closes odoo/odoo#123777 X-original-commit: 0e063bc142f13456935263caa07e6d840c1852f9 Signed-off-by: Brice Bartoletti (bib) Signed-off-by: Guillaume Merlin (megu) --- addons/account/models/account_move.py | 18 ++++++++++-------- .../account/report/account_invoice_report.py | 7 ++----- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/addons/account/models/account_move.py b/addons/account/models/account_move.py index 7fd2fa814d0..3e192dd21d1 100644 --- a/addons/account/models/account_move.py +++ b/addons/account/models/account_move.py @@ -38,6 +38,15 @@ _logger = logging.getLogger(__name__) MAX_HASH_VERSION = 3 +PAYMENT_STATE_SELECTION = [ + ('not_paid', 'Not Paid'), + ('in_payment', 'In Payment'), + ('paid', 'Paid'), + ('partial', 'Partially Paid'), + ('reversed', 'Reversed'), + ('invoicing_legacy', 'Invoicing App Legacy'), +] + TYPE_REVERSE_MAP = { 'entry': 'entry', 'out_invoice': 'out_refund', @@ -444,14 +453,7 @@ class AccountMove(models.Model): exportable=False, ) payment_state = fields.Selection( - selection=[ - ('not_paid', 'Not Paid'), - ('in_payment', 'In Payment'), - ('paid', 'Paid'), - ('partial', 'Partially Paid'), - ('reversed', 'Reversed'), - ('invoicing_legacy', 'Invoicing App Legacy'), - ], + selection=PAYMENT_STATE_SELECTION, string="Payment Status", compute='_compute_payment_state', store=True, readonly=True, copy=False, diff --git a/addons/account/report/account_invoice_report.py b/addons/account/report/account_invoice_report.py index 59eae586c8d..19e19eb7b0d 100644 --- a/addons/account/report/account_invoice_report.py +++ b/addons/account/report/account_invoice_report.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- from odoo import models, fields, api +from odoo.addons.account.models.account_move import PAYMENT_STATE_SELECTION from functools import lru_cache @@ -32,11 +33,7 @@ class AccountInvoiceReport(models.Model): ('posted', 'Open'), ('cancel', 'Cancelled') ], string='Invoice Status', readonly=True) - payment_state = fields.Selection(selection=[ - ('not_paid', 'Not Paid'), - ('in_payment', 'In Payment'), - ('paid', 'paid') - ], string='Payment Status', readonly=True) + payment_state = fields.Selection(selection=PAYMENT_STATE_SELECTION, string='Payment Status', readonly=True) fiscal_position_id = fields.Many2one('account.fiscal.position', string='Fiscal Position', readonly=True) invoice_date = fields.Date(readonly=True, string="Invoice Date")