From 8ab3e8290f61847ad09fd4ad1495275cbe520e7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adri=C3=A0=20Gil=20Sorribes?= Date: Mon, 18 May 2020 16:19:03 +0200 Subject: [PATCH] [12.0][IMP] account_skip_bank_reconciliation: allow to specify accounts to be proposed on reconciliation inside bank journal --- .../__manifest__.py | 1 + .../models/__init__.py | 1 + .../models/account_journal.py | 17 +++++++++++++++++ .../models/reconciliation_widget.py | 17 ++++++----------- .../readme/DESCRIPTION.rst | 4 +++- .../readme/USAGE.rst | 16 +++++++++++++--- .../views/account_journal_view.xml | 16 ++++++++++++++++ 7 files changed, 57 insertions(+), 15 deletions(-) create mode 100644 account_skip_bank_reconciliation/models/account_journal.py create mode 100644 account_skip_bank_reconciliation/views/account_journal_view.xml diff --git a/account_skip_bank_reconciliation/__manifest__.py b/account_skip_bank_reconciliation/__manifest__.py index 65bb35d2..f8f1199b 100644 --- a/account_skip_bank_reconciliation/__manifest__.py +++ b/account_skip_bank_reconciliation/__manifest__.py @@ -12,6 +12,7 @@ "category": "Finance", "data": [ "views/account_view.xml", + "views/account_journal_view.xml", ], 'license': 'AGPL-3', 'installable': True, diff --git a/account_skip_bank_reconciliation/models/__init__.py b/account_skip_bank_reconciliation/models/__init__.py index 1167b098..8a900762 100755 --- a/account_skip_bank_reconciliation/models/__init__.py +++ b/account_skip_bank_reconciliation/models/__init__.py @@ -1,5 +1,6 @@ # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). from . import account_account +from . import account_journal from . import reconciliation_widget from . import account_reconcile_model diff --git a/account_skip_bank_reconciliation/models/account_journal.py b/account_skip_bank_reconciliation/models/account_journal.py new file mode 100644 index 00000000..cccaa868 --- /dev/null +++ b/account_skip_bank_reconciliation/models/account_journal.py @@ -0,0 +1,17 @@ +# Copyright 2020 ForgeFlow S.L. +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). + +from odoo import fields, models + + +class AccountJournal(models.Model): + _inherit = "account.journal" + + account_reconciliation_ids = fields.Many2many( + relation="account_reconcile_account_journal_rel", + comodel_name="account.account", + string="Accounts to consider in reconciliation", + domain=[("reconcile", "=", True)], + help="If you enter accounts here they will be the only ones" + "to be considered during the reconciliation" + ) diff --git a/account_skip_bank_reconciliation/models/reconciliation_widget.py b/account_skip_bank_reconciliation/models/reconciliation_widget.py index 6ec92feb..28439338 100644 --- a/account_skip_bank_reconciliation/models/reconciliation_widget.py +++ b/account_skip_bank_reconciliation/models/reconciliation_widget.py @@ -17,15 +17,10 @@ class AccountReconciliation(models.AbstractModel): excluded_ids=excluded_ids, search_str=search_str) domain = expression.AND([domain, [ ("account_id.exclude_bank_reconcile", "!=", True)]]) - return domain - - @api.model - def _domain_move_lines_for_manual_reconciliation( - self, account_id, partner_id=False, - excluded_ids=None, search_str=False): - domain = super()._domain_move_lines_for_manual_reconciliation( - account_id, partner_id=partner_id, - excluded_ids=excluded_ids, search_str=search_str) - domain = expression.AND([domain, [ - ("account_id.exclude_bank_reconcile", "!=", True)]]) + # Extract from context allowed accounts defined in Journal, if any + journal_id = st_line.journal_id + account_reconciliation_ids = journal_id.account_reconciliation_ids + if account_reconciliation_ids: + domain = expression.AND([domain, [ + ("account_id", "in", account_reconciliation_ids.ids)]]) return domain diff --git a/account_skip_bank_reconciliation/readme/DESCRIPTION.rst b/account_skip_bank_reconciliation/readme/DESCRIPTION.rst index 3198c09b..44677112 100644 --- a/account_skip_bank_reconciliation/readme/DESCRIPTION.rst +++ b/account_skip_bank_reconciliation/readme/DESCRIPTION.rst @@ -1,5 +1,7 @@ This module allows to exclude from bank statement reconciliation -all journal items of a specific reconcilable account. +all journal items of a specific reconcilable account. It also allows +to specify in the Bank Journal which accounts should be taken into account +for reconciliation. Usually, you would want to that in accounts like the `Goods Received Not Invoiced`, which are required to be reconcilable diff --git a/account_skip_bank_reconciliation/readme/USAGE.rst b/account_skip_bank_reconciliation/readme/USAGE.rst index b5ffd6ba..dff0cfd9 100644 --- a/account_skip_bank_reconciliation/readme/USAGE.rst +++ b/account_skip_bank_reconciliation/readme/USAGE.rst @@ -1,5 +1,15 @@ -To use this module, you need to: +To use this module, you can choose one of the following approaches: -#. Go to `Invoicing / Configuration / Accounting / Charts of Accounts` +1. Go to `Invoicing / Configuration / Accounting / Charts of Accounts` and open a reconcilable account. -#. In that account, select or not the `Exclude from Bank Reconciliation` option. +2. In that account, select or not the `Exclude from Bank Reconciliation` option. + +or + +1. Go to `Invoicing / Configuration / Accounting / Journals` and open any + bank Journal +2. In the Journal select the accounts that you would like to be proposed in + reconciliations. + +Be careful, if an account is set to be excluded it will be excluded even if it +appears in the Bank Journal to be considered for reconciliation. diff --git a/account_skip_bank_reconciliation/views/account_journal_view.xml b/account_skip_bank_reconciliation/views/account_journal_view.xml new file mode 100644 index 00000000..6bb62361 --- /dev/null +++ b/account_skip_bank_reconciliation/views/account_journal_view.xml @@ -0,0 +1,16 @@ + + + + + account.journal + + + + + + + + + + +