diff --git a/account_bank_statement_line_reconciliation/__init__.py b/account_bank_statement_line_reconciliation/__init__.py index 8ea5e68a..2e691a95 100644 --- a/account_bank_statement_line_reconciliation/__init__.py +++ b/account_bank_statement_line_reconciliation/__init__.py @@ -2,4 +2,5 @@ # Copyright 2018 Camptocamp SA # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +from . import models from . import wizard diff --git a/account_bank_statement_line_reconciliation/__manifest__.py b/account_bank_statement_line_reconciliation/__manifest__.py index e9847fbc..a6d3c132 100644 --- a/account_bank_statement_line_reconciliation/__manifest__.py +++ b/account_bank_statement_line_reconciliation/__manifest__.py @@ -11,9 +11,13 @@ 'website': 'https://github.com/OCA/account-financial-reporting', 'license': 'AGPL-3', 'depends': [ + 'account', 'account_accountant', ], 'data': [ + # Views + 'views/res_config_settings_views.xml', + # Wizard 'wizard/account_bank_statement_line_reconciliation_wizard.xml', ], 'installable': True, diff --git a/account_bank_statement_line_reconciliation/models/__init__.py b/account_bank_statement_line_reconciliation/models/__init__.py new file mode 100644 index 00000000..8aea7e4f --- /dev/null +++ b/account_bank_statement_line_reconciliation/models/__init__.py @@ -0,0 +1,7 @@ +# -*- coding: utf-8 -*- +# Copyright 2018 Camptocamp SA +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from . import res_config_settings +from . import account_bank_statement +from . import company diff --git a/account_bank_statement_line_reconciliation/models/account_bank_statement.py b/account_bank_statement_line_reconciliation/models/account_bank_statement.py new file mode 100644 index 00000000..fdb994bb --- /dev/null +++ b/account_bank_statement_line_reconciliation/models/account_bank_statement.py @@ -0,0 +1,58 @@ +# -*- coding: utf-8 -*- + +from datetime import datetime +from odoo import models, fields, api +from odoo.osv import expression + +class AccountBankStatementLine(models.Model): + _inherit = "account.bank.statement.line" + + + def get_move_lines_for_reconciliation( + self, excluded_ids=None, str=False, offset=0, limit=None, + additional_domain=None, overlook_partner=False + ): + """ + Change the additional_domain to just see account statement line + with date after 'Bank Reconciliation Threshold' date + """ + + additional_domain = additional_domain or [] + rec_start = self.env.user.company_id.account_bank_reconciliation_start + if rec_start: + additional_domain.append(('date', '>', rec_start)) + + return super( + AccountBankStatementLine, self + ).get_move_lines_for_reconciliation( + excluded_ids=excluded_ids, + str=str, + offset=offset, + limit=limit, + additional_domain=additional_domain, + overlook_partner=overlook_partner + ) + + @api.multi + def get_data_for_reconciliation_widget(self, excluded_ids=None): + """ + Keep account bank statement line only if date line is after + 'Bank Reconciliation Threshold' date + """ + + excluded_ids = excluded_ids or [] + rec_start = self.env.user.company_id.account_bank_reconciliation_start + ret = [] + acc_bank_st_lines = super( + AccountBankStatementLine, self + ).get_data_for_reconciliation_widget(excluded_ids) + + if rec_start: + for acc_bank_st_line in acc_bank_st_lines: + st_line_date = acc_bank_st_line['st_line']['date'] + if st_line_date > rec_start: + ret.append(acc_bank_st_line) + else: + ret = acc_bank_st_lines + + return ret diff --git a/account_bank_statement_line_reconciliation/models/company.py b/account_bank_statement_line_reconciliation/models/company.py new file mode 100644 index 00000000..ca3d59b2 --- /dev/null +++ b/account_bank_statement_line_reconciliation/models/company.py @@ -0,0 +1,15 @@ +# -*- coding: utf-8 -*- + +from odoo import fields, models + +class ResCompany(models.Model): + _inherit = "res.company" + + account_bank_reconciliation_start = fields.Date( + string="Bank Reconciliation Threshold", + help="""The bank reconciliation widget won't ask to reconcile\ + payments older than this date.\ + This is useful if you install accounting after having used invoicing\ + for some time and don't want to reconcile all\ + the past payments with bank statements.""" + ) diff --git a/account_bank_statement_line_reconciliation/models/res_config_settings.py b/account_bank_statement_line_reconciliation/models/res_config_settings.py new file mode 100644 index 00000000..c4a64351 --- /dev/null +++ b/account_bank_statement_line_reconciliation/models/res_config_settings.py @@ -0,0 +1,18 @@ +# -*- coding: utf-8 -*- + +from odoo import fields, models + + +class AccountConfigSettings(models.TransientModel): + _inherit = 'account.config.settings' + + account_bank_reconciliation_start = fields.Date( + string="Bank Reconciliation Threshold", + related='company_id.account_bank_reconciliation_start', + readonly=False, + help="""The bank reconciliation widget won't ask to reconcile\ + payments older than this date.\ + This is useful if you install accounting after having used invoicing\ + for some time and don't want to reconcile all the past payments\ + with bank statements.""" + ) diff --git a/account_bank_statement_line_reconciliation/views/res_config_settings_views.xml b/account_bank_statement_line_reconciliation/views/res_config_settings_views.xml new file mode 100644 index 00000000..914b09c0 --- /dev/null +++ b/account_bank_statement_line_reconciliation/views/res_config_settings_views.xml @@ -0,0 +1,18 @@ + + + + extra.account.mass.reconcile.view.account.config + account.config.settings + + + + +
+
+
+ +
+
+