From c6fa784c43690d2a661c32a882db0c33de4464a8 Mon Sep 17 00:00:00 2001 From: "maximilien(malb)" Date: Fri, 23 Sep 2022 08:12:47 +0000 Subject: [PATCH] [FIX] account: Holes in sequences warning MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The warning should be displayed only on sales journal Also added the fact that the warning now depends on the lock date, if there is a lock date the warning is displayed for entries post lock date, otherwise it's for all the entries Same for the color of the name of the entry, it's now red only if it's post lock date closes odoo/odoo#101442 Task-id: 2993833 X-original-commit: c668d777a5984d1cdcfd45a90ec39e1a5a2e0a55 Signed-off-by: William André (wan) Signed-off-by: Maximilien La Barre (malb) --- addons/account/models/account_journal_dashboard.py | 2 ++ addons/account/models/account_move.py | 2 ++ addons/account/views/account_journal_dashboard_view.xml | 2 +- 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/addons/account/models/account_journal_dashboard.py b/addons/account/models/account_journal_dashboard.py index 80797ed9edd..8db08f9ff60 100644 --- a/addons/account/models/account_journal_dashboard.py +++ b/addons/account/models/account_journal_dashboard.py @@ -80,8 +80,10 @@ class account_journal(models.Model): SELECT move.journal_id, move.sequence_prefix FROM account_move move + JOIN res_company company ON company.id = move.company_id WHERE move.journal_id = ANY(%(journal_ids)s) AND move.state = 'posted' + AND (company.fiscalyear_lock_date IS NULL OR move.date >= company.fiscalyear_lock_date) GROUP BY move.journal_id, move.sequence_prefix HAVING COUNT(*) != MAX(move.sequence_number) - MIN(move.sequence_number) + 1 """, { diff --git a/addons/account/models/account_move.py b/addons/account/models/account_move.py index ebb108a1f95..bc7dca61325 100644 --- a/addons/account/models/account_move.py +++ b/addons/account/models/account_move.py @@ -745,6 +745,7 @@ class AccountMove(models.Model): self.env.cr.execute(""" SELECT this.id FROM account_move this + JOIN res_company company ON company.id = this.company_id LEFT JOIN account_move other ON this.journal_id = other.journal_id AND this.sequence_prefix = other.sequence_prefix AND this.sequence_number = other.sequence_number + 1 @@ -752,6 +753,7 @@ class AccountMove(models.Model): AND this.sequence_number != 1 AND this.name != '/' AND this.id = ANY(%(move_ids)s) + AND (company.fiscalyear_lock_date IS NULL OR this.date >= company.fiscalyear_lock_date) """, { 'move_ids': self.ids, }) diff --git a/addons/account/views/account_journal_dashboard_view.xml b/addons/account/views/account_journal_dashboard_view.xml index 82e4a2f50a4..4355a305763 100644 --- a/addons/account/views/account_journal_dashboard_view.xml +++ b/addons/account/views/account_journal_dashboard_view.xml @@ -79,7 +79,7 @@ - + Gaps in the sequence