From bdd60667c0cc4f6ea0ac48c4e9180e19661f2ae8 Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Fri, 9 Jun 2017 00:05:30 +0200 Subject: [PATCH 01/14] Add module account_bank_reconciliation_summary_xlsx --- .../README.rst | 65 ++++++ .../__init__.py | 4 + .../__manifest__.py | 18 ++ .../models/__init__.py | 3 + .../models/account_bank_statement.py | 22 ++ .../report/__init__.py | 3 + .../report/bank_reconciliation_xlsx.py | 200 ++++++++++++++++++ .../report/report.xml | 18 ++ .../views/account_bank_statement_view.xml | 23 ++ 9 files changed, 356 insertions(+) create mode 100644 account_bank_reconciliation_summary_xlsx/README.rst create mode 100644 account_bank_reconciliation_summary_xlsx/__init__.py create mode 100644 account_bank_reconciliation_summary_xlsx/__manifest__.py create mode 100644 account_bank_reconciliation_summary_xlsx/models/__init__.py create mode 100644 account_bank_reconciliation_summary_xlsx/models/account_bank_statement.py create mode 100644 account_bank_reconciliation_summary_xlsx/report/__init__.py create mode 100644 account_bank_reconciliation_summary_xlsx/report/bank_reconciliation_xlsx.py create mode 100644 account_bank_reconciliation_summary_xlsx/report/report.xml create mode 100644 account_bank_reconciliation_summary_xlsx/views/account_bank_statement_view.xml diff --git a/account_bank_reconciliation_summary_xlsx/README.rst b/account_bank_reconciliation_summary_xlsx/README.rst new file mode 100644 index 00000000..e0a3f6ee --- /dev/null +++ b/account_bank_reconciliation_summary_xlsx/README.rst @@ -0,0 +1,65 @@ +.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 + +=============================== +Bank Reconciliation Report XLSX +=============================== + +This module adds a Bank Reconciliation Report in Odoo in XLSX format. For each bank journal, the report displays: + +1. The balance of the bank account in the accounting, +2. The list of journal items of the bank account not linked to any bank statement lines, +3. The list of draft bank statement lines not linked to any journal items, +4. The computed balance of the bank account at the bank. + +The last field (computed balance of the bank account at the bank) must be compared to the real bank account balance at the bank. If there is a difference, you need to find the erreor in the accounting. The field *Computed balance of the bank account at the bank* is a formula, so you can easily change its computation to try to find the difference with the real bank account balance at the bank. + +Configuration +============= + +This module doesn't require any configuration. + +Usage +===== + +You can get the Bank Reconciliation Report from: + +* the form view of a bank bournal: click on *Print > Bank Reconciliation XLSX* +* the tree view of journals: select one or several journals and click on *Print > Bank Reconciliation XLSX* (if you selected several bank journals, you will get one tab per journal) +* the form view of a bank statement: click on the button *Bank Reconciliation Report*. + +.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas + :alt: Try me on Runbot + :target: https://runbot.odoo-community.org/runbot/91/10.0 + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues +`_. In case of trouble, please +check there if your issue has already been reported. If you spotted it first, +help us smashing it by providing a detailed and welcomed feedback. + +Credits +======= + +Contributors +------------ + +* Alexis de Lattre + +Maintainer +---------- + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +This module is maintained by the OCA. + +OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use. + +To contribute to this module, please visit https://odoo-community.org. diff --git a/account_bank_reconciliation_summary_xlsx/__init__.py b/account_bank_reconciliation_summary_xlsx/__init__.py new file mode 100644 index 00000000..7a6c1b03 --- /dev/null +++ b/account_bank_reconciliation_summary_xlsx/__init__.py @@ -0,0 +1,4 @@ +# -*- coding: utf-8 -*- + +from . import models +from . import report diff --git a/account_bank_reconciliation_summary_xlsx/__manifest__.py b/account_bank_reconciliation_summary_xlsx/__manifest__.py new file mode 100644 index 00000000..680a34e3 --- /dev/null +++ b/account_bank_reconciliation_summary_xlsx/__manifest__.py @@ -0,0 +1,18 @@ +# -*- coding: utf-8 -*- +# © 2017 Akretion (Alexis de Lattre ) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +{ + 'name': 'Account Bank Statement Reconciliation Summary', + 'version': '10.0.1.0.0', + 'license': 'AGPL-3', + 'author': "Akretion,Odoo Community Association (OCA)", + 'website': 'http://www.akretion.com', + 'summary': 'Adds an XLSX report to help on bank statement reconciliation', + 'depends': ['account', 'report_xlsx'], + 'data': [ + 'report/report.xml', + 'views/account_bank_statement_view.xml', + ], + 'installable': True, +} diff --git a/account_bank_reconciliation_summary_xlsx/models/__init__.py b/account_bank_reconciliation_summary_xlsx/models/__init__.py new file mode 100644 index 00000000..ac116473 --- /dev/null +++ b/account_bank_reconciliation_summary_xlsx/models/__init__.py @@ -0,0 +1,3 @@ +# -*- coding: utf-8 -*- + +from . import account_bank_statement diff --git a/account_bank_reconciliation_summary_xlsx/models/account_bank_statement.py b/account_bank_reconciliation_summary_xlsx/models/account_bank_statement.py new file mode 100644 index 00000000..d43c4219 --- /dev/null +++ b/account_bank_reconciliation_summary_xlsx/models/account_bank_statement.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +# © 2017 Akretion France (Alexis de Lattre ) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import models + + +class AccountBankStatement(models.Model): + _inherit = 'account.bank.statement' + + def print_reconciliation_xlsx(self): + self.ensure_one() + action = { + 'type': 'ir.actions.report.xml', + 'report_name': 'bank.reconciliation.xlsx', + 'datas': { + 'model': 'account.journal', + 'ids': [self.journal_id.id], + }, + 'context': self._context, + } + return action diff --git a/account_bank_reconciliation_summary_xlsx/report/__init__.py b/account_bank_reconciliation_summary_xlsx/report/__init__.py new file mode 100644 index 00000000..ce3ccb2c --- /dev/null +++ b/account_bank_reconciliation_summary_xlsx/report/__init__.py @@ -0,0 +1,3 @@ +# -*- coding: utf-8 -*- + +from . import bank_reconciliation_xlsx diff --git a/account_bank_reconciliation_summary_xlsx/report/bank_reconciliation_xlsx.py b/account_bank_reconciliation_summary_xlsx/report/bank_reconciliation_xlsx.py new file mode 100644 index 00000000..4e96c097 --- /dev/null +++ b/account_bank_reconciliation_summary_xlsx/report/bank_reconciliation_xlsx.py @@ -0,0 +1,200 @@ +# -*- coding: utf-8 -*- +# © 2017 Akretion France (Alexis de Lattre ) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo.addons.report_xlsx.report.report_xlsx import ReportXlsx +from odoo import _ +from odoo.tools import DEFAULT_SERVER_DATE_FORMAT +from datetime import datetime + + +class BankReconciliationXlsx(ReportXlsx): + + def generate_xlsx_report(self, workbook, data, journals): + no_bank_journal = True + for o in journals.filtered(lambda o: o.type == 'bank'): + no_bank_journal = False + # Start styles + doc_title = workbook.add_format({'bold': True, 'font_size': 16}) + col_title = workbook.add_format({ + 'bold': True, 'bg_color': '#e2e2fa', + 'text_wrap': True, 'font_size': 10, + }) + title_right = workbook.add_format({ + 'bold': True, 'bg_color': '#e6e6fa', + 'font_size': 10, 'align': 'right', + }) + label_bold = workbook.add_format({ + 'bold': True, 'text_wrap': False, 'font_size': 10}) + none = workbook.add_format({ + 'bold': True, 'font_size': 10, 'align': 'right'}) + regular = workbook.add_format({'font_size': 10}) + lang_code = self.env.user.lang + lang = False + if lang_code: + lang = self.env['res.lang'].search([('code', '=', lang_code)]) + if not lang: + lang = self.env['res.lang'].search([], limit=1) + xls_date_format = lang.date_format.replace('%Y', 'yyyy').\ + replace('%m', 'mm').replace('%d', 'dd').replace('%y', 'yy') + if '%' in xls_date_format: + # fallback + xls_date_format = 'yyyy-mm-dd' + regular_date = workbook.add_format({ + 'num_format': xls_date_format, + 'font_size': 10, + 'align': 'left'}) + cur_format = u'#%s##0%s00 %s' % ( + lang.thousands_sep or '', + lang.decimal_point or '', + o.company_id.currency_id.symbol or + o.company_id.currency_id.name) + regular_currency = workbook.add_format( + {'num_format': cur_format, 'font_size': 10}) + regular_currency_bg = workbook.add_format({ + 'num_format': cur_format, 'font_size': 10, + 'bg_color': '#f6f6ff'}) + # End styles + + sheet = workbook.add_worksheet(o.code or o.name) + sheet.write( + 0, 0, _('%s - Bank Reconciliation') % o.display_name, + doc_title) + sheet.set_row(0, 26) + sheet.set_row(1, 25) + sheet.set_column(0, 0, 10) + sheet.set_column(1, 1, 40) + sheet.set_column(2, 2, 15) + sheet.set_column(3, 3, 25) + sheet.set_column(4, 4, 12) + sheet.set_column(5, 5, 14) + sheet.set_column(6, 6, 22) + row = 2 + sheet.write(row, 0, _("Date:"), label_bold) + # I can't use fields.Date.context_today(self) + sheet.write(row, 1, datetime.today(), regular_date) + # 1) Show accounting balance of bank account + bank_account = o.default_debit_account_id + sheet.write( + row, 3, + _('Balance %s:') % bank_account.code, title_right) + amount_field = 'balance' + # TODO: add support for bank accounts in foreign currency + # if not o.currency_id else 'amount_currency' + query = """ + SELECT sum(%s) FROM account_move_line + WHERE account_id=%%s""" % (amount_field,) + self.env.cr.execute(query, (bank_account.id,)) + query_results = self.env.cr.dictfetchall() + if query_results: + account_bal = query_results[0].get('sum') or 0.0 + else: + account_bal = 0.0 + + sheet.write(row, 4, account_bal, regular_currency_bg) + bank_bal = account_bal + formula = '=E%d' % (row + 1) + # 2) Show account move line that are not linked to bank account + row += 2 + sheet.write( + row, 0, _( + 'Journal items of account %s not linked to a bank ' + 'statement line:') % bank_account.code, + label_bold) + mlines = self.env['account.move.line'].search([ + ('account_id', '=', bank_account.id), + ('journal_id', '=', o.id), # to avoid initial line + ('statement_id', '=', False)]) + if not mlines: + sheet.write(row, 4, _('NONE'), none) + else: + row += 1 + sheet.write(row, 0, _('Date'), col_title) + sheet.write(row, 1, _('Label'), col_title) + sheet.write(row, 2, _('Ref.'), col_title) + sheet.write(row, 3, _('Partner'), col_title) + sheet.write(row, 4, _('Amount'), col_title) + sheet.write(row, 5, _('Move Number'), col_title) + sheet.write(row, 6, _('Counter-part'), col_title) + m_start_row = m_end_row = row + 1 + for mline in mlines: + row += 1 + m_end_row = row + move = mline.move_id + bank_bal -= mline.balance + date_dt = datetime.strptime( + mline.date, DEFAULT_SERVER_DATE_FORMAT) + sheet.write(row, 0, date_dt, regular_date) + sheet.write(row, 1, mline.name, regular) + sheet.write(row, 2, mline.ref or '', regular) + sheet.write( + row, 3, mline.partner_id.display_name or '', regular) + sheet.write(row, 4, mline.balance, regular_currency) + sheet.write(row, 5, move.name, regular) + # counter-part accounts + cpart = [] + for line in move.line_ids: + if ( + line.account_id != bank_account and + line.account_id.code not in cpart): + cpart.append(line.account_id.code) + sheet.write(row, 6, ' ,'.join(cpart), regular) + + formula += '-SUM(E%d:E%d)' % (m_start_row + 1, m_end_row + 1) + + # 3) Add draft bank statement lines + row += 2 # skip 1 line + sheet.write( + row, 0, _( + 'Draft bank statement lines:'), + label_bold) + blines = self.env['account.bank.statement.line'].search([ + ('journal_entry_ids', '=', False), + ('journal_id', '=', o.id)]) + if not blines: + sheet.write(row, 4, _('NONE'), none) + else: + row += 1 + sheet.write(row, 0, _('Date'), col_title) + sheet.write(row, 1, _('Label'), col_title) + sheet.write(row, 2, _('Ref.'), col_title) + sheet.write(row, 3, _('Partner'), col_title) + sheet.write(row, 4, _('Amount'), col_title) + sheet.write(row, 5, _('Statement Ref.'), col_title) + b_start_row = b_end_row = row + 1 + for bline in blines: + row += 1 + b_end_row = row + bank_bal += bline.amount + date_dt = datetime.strptime( + bline.date, DEFAULT_SERVER_DATE_FORMAT) + sheet.write(row, 0, date_dt, regular_date) + sheet.write(row, 1, bline.name, regular) + sheet.write(row, 2, bline.ref or '', regular) + sheet.write( + row, 3, bline.partner_id.display_name or '', regular) + sheet.write(row, 4, bline.amount, regular_currency) + sheet.write( + row, 5, bline.statement_id.name or '', + regular_currency) + formula += '+SUM(E%d:E%d)' % (b_start_row + 1, b_end_row + 1) + + # 4) Theoric bank account balance at the bank + row += 2 + sheet.write( + row, 3, _('Computed Bank Account Balance at the Bank:'), + title_right) + sheet.write_formula( + row, 4, formula, regular_currency_bg, bank_bal) + if no_bank_journal: + sheet = workbook.add_worksheet(_('No Bank Journal')) + sheet.set_row(0, 30) + warn_msg = workbook.add_format( + {'bold': True, 'font_size': 16, 'font_color': '#003b6f'}) + sheet.write( + 0, 0, _( + "No bank journal selected. " + "This report is only for bank journals."), warn_msg) + + +BankReconciliationXlsx('report.bank.reconciliation.xlsx', 'account.journal') diff --git a/account_bank_reconciliation_summary_xlsx/report/report.xml b/account_bank_reconciliation_summary_xlsx/report/report.xml new file mode 100644 index 00000000..c7cb9677 --- /dev/null +++ b/account_bank_reconciliation_summary_xlsx/report/report.xml @@ -0,0 +1,18 @@ + + + + + + + + diff --git a/account_bank_reconciliation_summary_xlsx/views/account_bank_statement_view.xml b/account_bank_reconciliation_summary_xlsx/views/account_bank_statement_view.xml new file mode 100644 index 00000000..e124089b --- /dev/null +++ b/account_bank_reconciliation_summary_xlsx/views/account_bank_statement_view.xml @@ -0,0 +1,23 @@ + + + + + + + + bank_rec_summary.account.bank.statement.form + account.bank.statement + + + + + + + + From 2e7c55610ef82c609749d3659d7a6faf837ad4af Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Fri, 9 Jun 2017 00:38:54 +0200 Subject: [PATCH 02/14] Currency formatting with lang != en_US --- .../report/bank_reconciliation_xlsx.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/account_bank_reconciliation_summary_xlsx/report/bank_reconciliation_xlsx.py b/account_bank_reconciliation_summary_xlsx/report/bank_reconciliation_xlsx.py index 4e96c097..7c908ec2 100644 --- a/account_bank_reconciliation_summary_xlsx/report/bank_reconciliation_xlsx.py +++ b/account_bank_reconciliation_summary_xlsx/report/bank_reconciliation_xlsx.py @@ -44,11 +44,12 @@ class BankReconciliationXlsx(ReportXlsx): 'num_format': xls_date_format, 'font_size': 10, 'align': 'left'}) - cur_format = u'#%s##0%s00 %s' % ( - lang.thousands_sep or '', - lang.decimal_point or '', + cur_format = u'#,##0.00 %s' % ( o.company_id.currency_id.symbol or o.company_id.currency_id.name) + # It seems that Excel replaces automatically the decimal + # and thousand separator by those of the language under which + # Excel runs regular_currency = workbook.add_format( {'num_format': cur_format, 'font_size': 10}) regular_currency_bg = workbook.add_format({ From 0fa1370d7ee04f373f11b844295f1706686a0cc5 Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Fri, 9 Jun 2017 00:42:27 +0200 Subject: [PATCH 03/14] Update module name and summary --- account_bank_reconciliation_summary_xlsx/__manifest__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/account_bank_reconciliation_summary_xlsx/__manifest__.py b/account_bank_reconciliation_summary_xlsx/__manifest__.py index 680a34e3..fc857293 100644 --- a/account_bank_reconciliation_summary_xlsx/__manifest__.py +++ b/account_bank_reconciliation_summary_xlsx/__manifest__.py @@ -3,12 +3,12 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). { - 'name': 'Account Bank Statement Reconciliation Summary', + 'name': 'Bank Reconciliation Report', 'version': '10.0.1.0.0', 'license': 'AGPL-3', 'author': "Akretion,Odoo Community Association (OCA)", 'website': 'http://www.akretion.com', - 'summary': 'Adds an XLSX report to help on bank statement reconciliation', + 'summary': 'Adds an XLSX report to help on bank reconciliation', 'depends': ['account', 'report_xlsx'], 'data': [ 'report/report.xml', From 03c1a8924ac61574a2045bafdbc70e4aa9128dd1 Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Sun, 29 Oct 2017 00:29:01 +0200 Subject: [PATCH 04/14] Support bank reconciliation summary on date != today Add wizard for that report --- .../__init__.py | 1 + .../__manifest__.py | 4 +- .../models/__init__.py | 1 + .../models/account_move_line.py | 13 +++++ .../report/bank_reconciliation_xlsx.py | 58 ++++++++++++------- ...nt_view.xml => account_bank_statement.xml} | 0 .../views/account_move_line.xml | 22 +++++++ .../wizard/__init__.py | 3 + .../bank_reconciliation_report_wizard.py | 41 +++++++++++++ ...bank_reconciliation_report_wizard_view.xml | 36 ++++++++++++ 10 files changed, 157 insertions(+), 22 deletions(-) create mode 100644 account_bank_reconciliation_summary_xlsx/models/account_move_line.py rename account_bank_reconciliation_summary_xlsx/views/{account_bank_statement_view.xml => account_bank_statement.xml} (100%) create mode 100644 account_bank_reconciliation_summary_xlsx/views/account_move_line.xml create mode 100644 account_bank_reconciliation_summary_xlsx/wizard/__init__.py create mode 100644 account_bank_reconciliation_summary_xlsx/wizard/bank_reconciliation_report_wizard.py create mode 100644 account_bank_reconciliation_summary_xlsx/wizard/bank_reconciliation_report_wizard_view.xml diff --git a/account_bank_reconciliation_summary_xlsx/__init__.py b/account_bank_reconciliation_summary_xlsx/__init__.py index 7a6c1b03..de9509a6 100644 --- a/account_bank_reconciliation_summary_xlsx/__init__.py +++ b/account_bank_reconciliation_summary_xlsx/__init__.py @@ -2,3 +2,4 @@ from . import models from . import report +from . import wizard diff --git a/account_bank_reconciliation_summary_xlsx/__manifest__.py b/account_bank_reconciliation_summary_xlsx/__manifest__.py index fc857293..0f25db90 100644 --- a/account_bank_reconciliation_summary_xlsx/__manifest__.py +++ b/account_bank_reconciliation_summary_xlsx/__manifest__.py @@ -12,7 +12,9 @@ 'depends': ['account', 'report_xlsx'], 'data': [ 'report/report.xml', - 'views/account_bank_statement_view.xml', + 'views/account_bank_statement.xml', + 'views/account_move_line.xml', + 'wizard/bank_reconciliation_report_wizard_view.xml', ], 'installable': True, } diff --git a/account_bank_reconciliation_summary_xlsx/models/__init__.py b/account_bank_reconciliation_summary_xlsx/models/__init__.py index ac116473..a7a3402d 100644 --- a/account_bank_reconciliation_summary_xlsx/models/__init__.py +++ b/account_bank_reconciliation_summary_xlsx/models/__init__.py @@ -1,3 +1,4 @@ # -*- coding: utf-8 -*- from . import account_bank_statement +from . import account_move_line diff --git a/account_bank_reconciliation_summary_xlsx/models/account_move_line.py b/account_bank_reconciliation_summary_xlsx/models/account_move_line.py new file mode 100644 index 00000000..21727012 --- /dev/null +++ b/account_bank_reconciliation_summary_xlsx/models/account_move_line.py @@ -0,0 +1,13 @@ +# -*- coding: utf-8 -*- +# © 2017 Akretion (Alexis de Lattre ) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import fields, models + + +class AccountMoveLine(models.Model): + _inherit = 'account.move.line' + + statement_line_date = fields.Date( + string='Statement Line Date', + related='move_id.statement_line_id.date', store=True, readonly=True) diff --git a/account_bank_reconciliation_summary_xlsx/report/bank_reconciliation_xlsx.py b/account_bank_reconciliation_summary_xlsx/report/bank_reconciliation_xlsx.py index 7c908ec2..9eb12362 100644 --- a/account_bank_reconciliation_summary_xlsx/report/bank_reconciliation_xlsx.py +++ b/account_bank_reconciliation_summary_xlsx/report/bank_reconciliation_xlsx.py @@ -3,7 +3,7 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). from odoo.addons.report_xlsx.report.report_xlsx import ReportXlsx -from odoo import _ +from odoo import fields, _ from odoo.tools import DEFAULT_SERVER_DATE_FORMAT from datetime import datetime @@ -11,10 +11,22 @@ from datetime import datetime class BankReconciliationXlsx(ReportXlsx): def generate_xlsx_report(self, workbook, data, journals): + # I can't use fields.Date.context_today(self) + date = data.get('date') or datetime.today() + date_dt = fields.Date.from_string(date) no_bank_journal = True for o in journals.filtered(lambda o: o.type == 'bank'): no_bank_journal = False # Start styles + lang_code = self.env.user.lang + lang = False + if lang_code: + lang = self.env['res.lang'].search([('code', '=', lang_code)]) + if not lang: + lang = self.env['res.lang'].search([], limit=1) + xls_date_format = lang.date_format.replace('%Y', 'yyyy').\ + replace('%m', 'mm').replace('%d', 'dd').replace('%y', 'yy') + doc_title = workbook.add_format({'bold': True, 'font_size': 16}) col_title = workbook.add_format({ 'bold': True, 'bg_color': '#e2e2fa', @@ -24,19 +36,16 @@ class BankReconciliationXlsx(ReportXlsx): 'bold': True, 'bg_color': '#e6e6fa', 'font_size': 10, 'align': 'right', }) + title_date = workbook.add_format({ + 'bg_color': '#f6f6ff', 'bold': True, + 'num_format': xls_date_format, + 'font_size': 10, + 'align': 'left'}) label_bold = workbook.add_format({ 'bold': True, 'text_wrap': False, 'font_size': 10}) none = workbook.add_format({ 'bold': True, 'font_size': 10, 'align': 'right'}) regular = workbook.add_format({'font_size': 10}) - lang_code = self.env.user.lang - lang = False - if lang_code: - lang = self.env['res.lang'].search([('code', '=', lang_code)]) - if not lang: - lang = self.env['res.lang'].search([], limit=1) - xls_date_format = lang.date_format.replace('%Y', 'yyyy').\ - replace('%m', 'mm').replace('%d', 'dd').replace('%y', 'yy') if '%' in xls_date_format: # fallback xls_date_format = 'yyyy-mm-dd' @@ -71,10 +80,10 @@ class BankReconciliationXlsx(ReportXlsx): sheet.set_column(5, 5, 14) sheet.set_column(6, 6, 22) row = 2 - sheet.write(row, 0, _("Date:"), label_bold) - # I can't use fields.Date.context_today(self) - sheet.write(row, 1, datetime.today(), regular_date) + sheet.write(row, 0, _("Date:"), title_right) + sheet.write(row, 1, date_dt, title_date) # 1) Show accounting balance of bank account + row += 1 bank_account = o.default_debit_account_id sheet.write( row, 3, @@ -84,8 +93,8 @@ class BankReconciliationXlsx(ReportXlsx): # if not o.currency_id else 'amount_currency' query = """ SELECT sum(%s) FROM account_move_line - WHERE account_id=%%s""" % (amount_field,) - self.env.cr.execute(query, (bank_account.id,)) + WHERE account_id=%%s AND date <= %%s""" % (amount_field, ) + self.env.cr.execute(query, (bank_account.id, date)) query_results = self.env.cr.dictfetchall() if query_results: account_bal = query_results[0].get('sum') or 0.0 @@ -95,7 +104,8 @@ class BankReconciliationXlsx(ReportXlsx): sheet.write(row, 4, account_bal, regular_currency_bg) bank_bal = account_bal formula = '=E%d' % (row + 1) - # 2) Show account move line that are not linked to bank account + # 2) Show account move line that are not linked to bank statement + # line or linked to a statement line after the date row += 2 sheet.write( row, 0, _( @@ -105,7 +115,9 @@ class BankReconciliationXlsx(ReportXlsx): mlines = self.env['account.move.line'].search([ ('account_id', '=', bank_account.id), ('journal_id', '=', o.id), # to avoid initial line - ('statement_id', '=', False)]) + ('date', '<=', date), + '|', ('statement_line_date', '=', False), + ('statement_line_date', '>', date)]) if not mlines: sheet.write(row, 4, _('NONE'), none) else: @@ -115,8 +127,9 @@ class BankReconciliationXlsx(ReportXlsx): sheet.write(row, 2, _('Ref.'), col_title) sheet.write(row, 3, _('Partner'), col_title) sheet.write(row, 4, _('Amount'), col_title) - sheet.write(row, 5, _('Move Number'), col_title) - sheet.write(row, 6, _('Counter-part'), col_title) + sheet.write(row, 5, _('Statement Line Date'), col_title) + sheet.write(row, 6, _('Move Number'), col_title) + sheet.write(row, 7, _('Counter-part'), col_title) m_start_row = m_end_row = row + 1 for mline in mlines: row += 1 @@ -131,7 +144,9 @@ class BankReconciliationXlsx(ReportXlsx): sheet.write( row, 3, mline.partner_id.display_name or '', regular) sheet.write(row, 4, mline.balance, regular_currency) - sheet.write(row, 5, move.name, regular) + sheet.write( + row, 5, mline.statement_line_date, regular_date) + sheet.write(row, 6, move.name, regular) # counter-part accounts cpart = [] for line in move.line_ids: @@ -139,7 +154,7 @@ class BankReconciliationXlsx(ReportXlsx): line.account_id != bank_account and line.account_id.code not in cpart): cpart.append(line.account_id.code) - sheet.write(row, 6, ' ,'.join(cpart), regular) + sheet.write(row, 7, ' ,'.join(cpart), regular) formula += '-SUM(E%d:E%d)' % (m_start_row + 1, m_end_row + 1) @@ -151,7 +166,8 @@ class BankReconciliationXlsx(ReportXlsx): label_bold) blines = self.env['account.bank.statement.line'].search([ ('journal_entry_ids', '=', False), - ('journal_id', '=', o.id)]) + ('journal_id', '=', o.id), + ('date', '<=', date)]) if not blines: sheet.write(row, 4, _('NONE'), none) else: diff --git a/account_bank_reconciliation_summary_xlsx/views/account_bank_statement_view.xml b/account_bank_reconciliation_summary_xlsx/views/account_bank_statement.xml similarity index 100% rename from account_bank_reconciliation_summary_xlsx/views/account_bank_statement_view.xml rename to account_bank_reconciliation_summary_xlsx/views/account_bank_statement.xml diff --git a/account_bank_reconciliation_summary_xlsx/views/account_move_line.xml b/account_bank_reconciliation_summary_xlsx/views/account_move_line.xml new file mode 100644 index 00000000..7e03af6c --- /dev/null +++ b/account_bank_reconciliation_summary_xlsx/views/account_move_line.xml @@ -0,0 +1,22 @@ + + + + + + + + bank_rec_summarry.account_move_line_form + account.move.line + + + + + + + + + + diff --git a/account_bank_reconciliation_summary_xlsx/wizard/__init__.py b/account_bank_reconciliation_summary_xlsx/wizard/__init__.py new file mode 100644 index 00000000..02696cfe --- /dev/null +++ b/account_bank_reconciliation_summary_xlsx/wizard/__init__.py @@ -0,0 +1,3 @@ +# -*- coding: utf-8 -*- + +from . import bank_reconciliation_report_wizard diff --git a/account_bank_reconciliation_summary_xlsx/wizard/bank_reconciliation_report_wizard.py b/account_bank_reconciliation_summary_xlsx/wizard/bank_reconciliation_report_wizard.py new file mode 100644 index 00000000..1370a98a --- /dev/null +++ b/account_bank_reconciliation_summary_xlsx/wizard/bank_reconciliation_report_wizard.py @@ -0,0 +1,41 @@ +# -*- coding: utf-8 -*- +# © 2017 Akretion (Alexis de Lattre ) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import api, fields, models + + +class BankReconciliationReportWizard(models.TransientModel): + _name = "bank.reconciliation.report.wizard" + _description = "Bank Reconciliation Report Wizard" + + @api.model + def _default_journal_ids(self): + journals = self.env['account.journal'].search([ + ('type', '=', 'bank'), + ('company_id', '=', self.env.user.company_id.id)]) + return journals + + company_id = fields.Many2one( + 'res.company', string='Company', + default=lambda self: self.env.user.company_id) + date = fields.Date( + required=True, + default=fields.Date.context_today) + journal_ids = fields.Many2many( + 'account.journal', string='Bank Journals', + domain=[('type', '=', 'bank')], required=True, + default=_default_journal_ids) + + def open_xlsx(self): + action = { + 'type': 'ir.actions.report.xml', + 'report_name': 'bank.reconciliation.xlsx', + 'datas': { + 'model': 'account.journal', + 'ids': self.journal_ids.ids, + 'date': self.date, + }, + 'context': self._context, + } + return action diff --git a/account_bank_reconciliation_summary_xlsx/wizard/bank_reconciliation_report_wizard_view.xml b/account_bank_reconciliation_summary_xlsx/wizard/bank_reconciliation_report_wizard_view.xml new file mode 100644 index 00000000..841d8ff1 --- /dev/null +++ b/account_bank_reconciliation_summary_xlsx/wizard/bank_reconciliation_report_wizard_view.xml @@ -0,0 +1,36 @@ + + + + + + + bank.reconciliation.report.wizard.form + bank.reconciliation.report.wizard + +
+ + + + + +
+
+
+
+
+ + + Bank Reconciliation Report + bank.reconciliation.report.wizard + form + new + + + + +
From ef250fbb639199225ea655fe0d6a92d5aff4b8b3 Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Sun, 29 Oct 2017 02:16:48 +0200 Subject: [PATCH 05/14] Fine tune layout bank reconciliation report Report is technically linked to wizard, not to account.journal --- .../__manifest__.py | 2 +- .../models/__init__.py | 1 - .../models/account_bank_statement.py | 22 ------- .../report/bank_reconciliation_xlsx.py | 61 +++++++++++-------- .../report/report.xml | 2 +- .../views/account_bank_statement.xml | 4 +- .../bank_reconciliation_report_wizard.py | 8 +-- ...bank_reconciliation_report_wizard_view.xml | 3 +- 8 files changed, 44 insertions(+), 59 deletions(-) delete mode 100644 account_bank_reconciliation_summary_xlsx/models/account_bank_statement.py diff --git a/account_bank_reconciliation_summary_xlsx/__manifest__.py b/account_bank_reconciliation_summary_xlsx/__manifest__.py index 0f25db90..97b80d32 100644 --- a/account_bank_reconciliation_summary_xlsx/__manifest__.py +++ b/account_bank_reconciliation_summary_xlsx/__manifest__.py @@ -12,9 +12,9 @@ 'depends': ['account', 'report_xlsx'], 'data': [ 'report/report.xml', + 'wizard/bank_reconciliation_report_wizard_view.xml', 'views/account_bank_statement.xml', 'views/account_move_line.xml', - 'wizard/bank_reconciliation_report_wizard_view.xml', ], 'installable': True, } diff --git a/account_bank_reconciliation_summary_xlsx/models/__init__.py b/account_bank_reconciliation_summary_xlsx/models/__init__.py index a7a3402d..0c1006db 100644 --- a/account_bank_reconciliation_summary_xlsx/models/__init__.py +++ b/account_bank_reconciliation_summary_xlsx/models/__init__.py @@ -1,4 +1,3 @@ # -*- coding: utf-8 -*- -from . import account_bank_statement from . import account_move_line diff --git a/account_bank_reconciliation_summary_xlsx/models/account_bank_statement.py b/account_bank_reconciliation_summary_xlsx/models/account_bank_statement.py deleted file mode 100644 index d43c4219..00000000 --- a/account_bank_reconciliation_summary_xlsx/models/account_bank_statement.py +++ /dev/null @@ -1,22 +0,0 @@ -# -*- coding: utf-8 -*- -# © 2017 Akretion France (Alexis de Lattre ) -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). - -from odoo import models - - -class AccountBankStatement(models.Model): - _inherit = 'account.bank.statement' - - def print_reconciliation_xlsx(self): - self.ensure_one() - action = { - 'type': 'ir.actions.report.xml', - 'report_name': 'bank.reconciliation.xlsx', - 'datas': { - 'model': 'account.journal', - 'ids': [self.journal_id.id], - }, - 'context': self._context, - } - return action diff --git a/account_bank_reconciliation_summary_xlsx/report/bank_reconciliation_xlsx.py b/account_bank_reconciliation_summary_xlsx/report/bank_reconciliation_xlsx.py index 9eb12362..b9ca49cd 100644 --- a/account_bank_reconciliation_summary_xlsx/report/bank_reconciliation_xlsx.py +++ b/account_bank_reconciliation_summary_xlsx/report/bank_reconciliation_xlsx.py @@ -10,12 +10,11 @@ from datetime import datetime class BankReconciliationXlsx(ReportXlsx): - def generate_xlsx_report(self, workbook, data, journals): - # I can't use fields.Date.context_today(self) - date = data.get('date') or datetime.today() + def generate_xlsx_report(self, workbook, data, wizard): + date = wizard.date date_dt = fields.Date.from_string(date) no_bank_journal = True - for o in journals.filtered(lambda o: o.type == 'bank'): + for o in wizard.journal_ids: no_bank_journal = False # Start styles lang_code = self.env.user.lang @@ -77,14 +76,17 @@ class BankReconciliationXlsx(ReportXlsx): sheet.set_column(2, 2, 15) sheet.set_column(3, 3, 25) sheet.set_column(4, 4, 12) - sheet.set_column(5, 5, 14) - sheet.set_column(6, 6, 22) + sheet.set_column(5, 5, 18) + sheet.set_column(6, 6, 14) + sheet.set_column(7, 7, 14) row = 2 sheet.write(row, 0, _("Date:"), title_right) sheet.write(row, 1, date_dt, title_date) # 1) Show accounting balance of bank account - row += 1 + row += 2 bank_account = o.default_debit_account_id + for col in range(3): + sheet.write(row, col, '', title_right) sheet.write( row, 3, _('Balance %s:') % bank_account.code, title_right) @@ -122,30 +124,33 @@ class BankReconciliationXlsx(ReportXlsx): sheet.write(row, 4, _('NONE'), none) else: row += 1 - sheet.write(row, 0, _('Date'), col_title) - sheet.write(row, 1, _('Label'), col_title) - sheet.write(row, 2, _('Ref.'), col_title) - sheet.write(row, 3, _('Partner'), col_title) - sheet.write(row, 4, _('Amount'), col_title) - sheet.write(row, 5, _('Statement Line Date'), col_title) - sheet.write(row, 6, _('Move Number'), col_title) - sheet.write(row, 7, _('Counter-part'), col_title) + col_labels = [ + _('Date'), _('Label'), _('Ref.'), _('Partner'), + _('Amount'), _('Statement Line Date'), _('Move Number'), + _('Counter-part')] + col = 0 + for col_label in col_labels: + sheet.write(row, col, col_label, col_title) + col += 1 m_start_row = m_end_row = row + 1 for mline in mlines: row += 1 m_end_row = row move = mline.move_id bank_bal -= mline.balance - date_dt = datetime.strptime( - mline.date, DEFAULT_SERVER_DATE_FORMAT) + date_dt = fields.Date.from_string(mline.date) sheet.write(row, 0, date_dt, regular_date) sheet.write(row, 1, mline.name, regular) sheet.write(row, 2, mline.ref or '', regular) sheet.write( row, 3, mline.partner_id.display_name or '', regular) sheet.write(row, 4, mline.balance, regular_currency) - sheet.write( - row, 5, mline.statement_line_date, regular_date) + if mline.statement_line_date: + stl_date_dt = fields.Date.from_string( + mline.statement_line_date) + else: + stl_date_dt = '' + sheet.write(row, 5, stl_date_dt, regular_date) sheet.write(row, 6, move.name, regular) # counter-part accounts cpart = [] @@ -172,12 +177,13 @@ class BankReconciliationXlsx(ReportXlsx): sheet.write(row, 4, _('NONE'), none) else: row += 1 - sheet.write(row, 0, _('Date'), col_title) - sheet.write(row, 1, _('Label'), col_title) - sheet.write(row, 2, _('Ref.'), col_title) - sheet.write(row, 3, _('Partner'), col_title) - sheet.write(row, 4, _('Amount'), col_title) - sheet.write(row, 5, _('Statement Ref.'), col_title) + col_labels = [ + _('Date'), _('Label'), _('Ref.'), + _('Partner'), _('Amount'), _('Statement Ref.'), '', ''] + col = 0 + for col_label in col_labels: + sheet.write(row, col, col_label, col_title) + col += 1 b_start_row = b_end_row = row + 1 for bline in blines: row += 1 @@ -198,6 +204,8 @@ class BankReconciliationXlsx(ReportXlsx): # 4) Theoric bank account balance at the bank row += 2 + for col in range(3): + sheet.write(row, col, '', title_right) sheet.write( row, 3, _('Computed Bank Account Balance at the Bank:'), title_right) @@ -214,4 +222,5 @@ class BankReconciliationXlsx(ReportXlsx): "This report is only for bank journals."), warn_msg) -BankReconciliationXlsx('report.bank.reconciliation.xlsx', 'account.journal') +BankReconciliationXlsx( + 'report.bank.reconciliation.xlsx', 'bank.reconciliation.report.wizard') diff --git a/account_bank_reconciliation_summary_xlsx/report/report.xml b/account_bank_reconciliation_summary_xlsx/report/report.xml index c7cb9677..8a855b44 100644 --- a/account_bank_reconciliation_summary_xlsx/report/report.xml +++ b/account_bank_reconciliation_summary_xlsx/report/report.xml @@ -8,7 +8,7 @@ diff --git a/account_bank_reconciliation_summary_xlsx/wizard/bank_reconciliation_report_wizard.py b/account_bank_reconciliation_summary_xlsx/wizard/bank_reconciliation_report_wizard.py index 1370a98a..9c887bd5 100644 --- a/account_bank_reconciliation_summary_xlsx/wizard/bank_reconciliation_report_wizard.py +++ b/account_bank_reconciliation_summary_xlsx/wizard/bank_reconciliation_report_wizard.py @@ -16,9 +16,6 @@ class BankReconciliationReportWizard(models.TransientModel): ('company_id', '=', self.env.user.company_id.id)]) return journals - company_id = fields.Many2one( - 'res.company', string='Company', - default=lambda self: self.env.user.company_id) date = fields.Date( required=True, default=fields.Date.context_today) @@ -32,8 +29,9 @@ class BankReconciliationReportWizard(models.TransientModel): 'type': 'ir.actions.report.xml', 'report_name': 'bank.reconciliation.xlsx', 'datas': { - 'model': 'account.journal', - 'ids': self.journal_ids.ids, + 'model': self._name, + 'ids': self.ids, + 'journal_ids': self.journal_ids.ids, 'date': self.date, }, 'context': self._context, diff --git a/account_bank_reconciliation_summary_xlsx/wizard/bank_reconciliation_report_wizard_view.xml b/account_bank_reconciliation_summary_xlsx/wizard/bank_reconciliation_report_wizard_view.xml index 841d8ff1..8ee3d6e6 100644 --- a/account_bank_reconciliation_summary_xlsx/wizard/bank_reconciliation_report_wizard_view.xml +++ b/account_bank_reconciliation_summary_xlsx/wizard/bank_reconciliation_report_wizard_view.xml @@ -6,13 +6,13 @@ + bank.reconciliation.report.wizard.form bank.reconciliation.report.wizard
- @@ -33,4 +33,5 @@ + From 03d5147afeef3d66cc6732a324eb4b40ca940f5f Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Sun, 29 Oct 2017 02:22:41 +0200 Subject: [PATCH 06/14] Put menu entry of Bank Reconciliation Report under OCA reports --- account_bank_reconciliation_summary_xlsx/README.rst | 5 ++--- account_bank_reconciliation_summary_xlsx/__manifest__.py | 2 +- .../wizard/bank_reconciliation_report_wizard_view.xml | 4 ++-- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/account_bank_reconciliation_summary_xlsx/README.rst b/account_bank_reconciliation_summary_xlsx/README.rst index e0a3f6ee..fd4cb162 100644 --- a/account_bank_reconciliation_summary_xlsx/README.rst +++ b/account_bank_reconciliation_summary_xlsx/README.rst @@ -23,10 +23,9 @@ This module doesn't require any configuration. Usage ===== -You can get the Bank Reconciliation Report from: +You can launch the Bank Reconciliation Report wizard from: -* the form view of a bank bournal: click on *Print > Bank Reconciliation XLSX* -* the tree view of journals: select one or several journals and click on *Print > Bank Reconciliation XLSX* (if you selected several bank journals, you will get one tab per journal) +* the menu *Accounting > Reports > OCA accounting reports > Bank Reconciliation*, * the form view of a bank statement: click on the button *Bank Reconciliation Report*. .. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas diff --git a/account_bank_reconciliation_summary_xlsx/__manifest__.py b/account_bank_reconciliation_summary_xlsx/__manifest__.py index 97b80d32..4ea8f420 100644 --- a/account_bank_reconciliation_summary_xlsx/__manifest__.py +++ b/account_bank_reconciliation_summary_xlsx/__manifest__.py @@ -9,7 +9,7 @@ 'author': "Akretion,Odoo Community Association (OCA)", 'website': 'http://www.akretion.com', 'summary': 'Adds an XLSX report to help on bank reconciliation', - 'depends': ['account', 'report_xlsx'], + 'depends': ['account_financial_report_qweb', 'report_xlsx'], 'data': [ 'report/report.xml', 'wizard/bank_reconciliation_report_wizard_view.xml', diff --git a/account_bank_reconciliation_summary_xlsx/wizard/bank_reconciliation_report_wizard_view.xml b/account_bank_reconciliation_summary_xlsx/wizard/bank_reconciliation_report_wizard_view.xml index 8ee3d6e6..13227916 100644 --- a/account_bank_reconciliation_summary_xlsx/wizard/bank_reconciliation_report_wizard_view.xml +++ b/account_bank_reconciliation_summary_xlsx/wizard/bank_reconciliation_report_wizard_view.xml @@ -25,13 +25,13 @@ - Bank Reconciliation Report + Bank Reconciliation bank.reconciliation.report.wizard form new - + From 3225a98420bb2fd61686f9c91f3c8d339f008c77 Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Sun, 29 Oct 2017 12:32:08 +0100 Subject: [PATCH 07/14] =?UTF-8?q?Fix=20typo=20in=20README=20found=20by=20R?= =?UTF-8?q?apha=C3=ABl=20Valyi?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- account_bank_reconciliation_summary_xlsx/README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/account_bank_reconciliation_summary_xlsx/README.rst b/account_bank_reconciliation_summary_xlsx/README.rst index fd4cb162..447639d4 100644 --- a/account_bank_reconciliation_summary_xlsx/README.rst +++ b/account_bank_reconciliation_summary_xlsx/README.rst @@ -13,7 +13,7 @@ This module adds a Bank Reconciliation Report in Odoo in XLSX format. For each b 3. The list of draft bank statement lines not linked to any journal items, 4. The computed balance of the bank account at the bank. -The last field (computed balance of the bank account at the bank) must be compared to the real bank account balance at the bank. If there is a difference, you need to find the erreor in the accounting. The field *Computed balance of the bank account at the bank* is a formula, so you can easily change its computation to try to find the difference with the real bank account balance at the bank. +The last field (computed balance of the bank account at the bank) must be compared to the real bank account balance at the bank. If there is a difference, you need to find the error in the accounting. The field *Computed balance of the bank account at the bank* is a formula, so you can easily change its computation to try to find the difference with the real bank account balance at the bank. Configuration ============= From 9938e6e187585cda14b6eac24ada8ce25fb2d608 Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Sat, 24 Mar 2018 14:18:38 +0100 Subject: [PATCH 08/14] Access to Bank reconciliation report from accounting dashboard Code written during the Tryton conference at JDLL 2018 :) --- .../__manifest__.py | 1 + .../views/account_journal.xml | 31 +++++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 account_bank_reconciliation_summary_xlsx/views/account_journal.xml diff --git a/account_bank_reconciliation_summary_xlsx/__manifest__.py b/account_bank_reconciliation_summary_xlsx/__manifest__.py index 4ea8f420..de9c9a43 100644 --- a/account_bank_reconciliation_summary_xlsx/__manifest__.py +++ b/account_bank_reconciliation_summary_xlsx/__manifest__.py @@ -15,6 +15,7 @@ 'wizard/bank_reconciliation_report_wizard_view.xml', 'views/account_bank_statement.xml', 'views/account_move_line.xml', + 'views/account_journal.xml', ], 'installable': True, } diff --git a/account_bank_reconciliation_summary_xlsx/views/account_journal.xml b/account_bank_reconciliation_summary_xlsx/views/account_journal.xml new file mode 100644 index 00000000..35c9d999 --- /dev/null +++ b/account_bank_reconciliation_summary_xlsx/views/account_journal.xml @@ -0,0 +1,31 @@ + + + + + + + + bank_reconciliation_summarry.account_journal_dashboard + account.journal + + + +
+
+ Report +
+ +
+
+
+
+ + +
From 05cc0c53c62d6256b03067faee04062c34c13b72 Mon Sep 17 00:00:00 2001 From: Mourad EL HADJ MIMOUNE Date: Tue, 4 Dec 2018 16:29:45 +0100 Subject: [PATCH 09/14] add fr.po & filter default journal by bank_account_id & usee statement.display_name --- .../i18n/fr.po | 216 ++++++++++++++++++ .../report/bank_reconciliation_xlsx.py | 2 +- .../bank_reconciliation_report_wizard.py | 4 +- 3 files changed, 220 insertions(+), 2 deletions(-) create mode 100644 account_bank_reconciliation_summary_xlsx/i18n/fr.po diff --git a/account_bank_reconciliation_summary_xlsx/i18n/fr.po b/account_bank_reconciliation_summary_xlsx/i18n/fr.po new file mode 100644 index 00000000..2cfe1d92 --- /dev/null +++ b/account_bank_reconciliation_summary_xlsx/i18n/fr.po @@ -0,0 +1,216 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * account_bank_reconciliation_summary_xlsx +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 10.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2018-12-04 10:29+0000\n" +"PO-Revision-Date: 2018-12-04 10:29+0000\n" +"Last-Translator: <>\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: account_bank_reconciliation_summary_xlsx +#: code:addons/account_bank_reconciliation_summary_xlsx/report/bank_reconciliation_xlsx.py:70 +#, python-format +msgid "%s - Bank Reconciliation" +msgstr "%s - Rapprochement bancaire" + +#. module: account_bank_reconciliation_summary_xlsx +#: model:ir.ui.view,arch_db:account_bank_reconciliation_summary_xlsx.account_journal_dashboard_kanban_view +msgid "Report" +msgstr "Raport" + +#. module: account_bank_reconciliation_summary_xlsx +#: code:addons/account_bank_reconciliation_summary_xlsx/report/bank_reconciliation_xlsx.py:129 +#: code:addons/account_bank_reconciliation_summary_xlsx/report/bank_reconciliation_xlsx.py:182 +#, python-format +msgid "Amount" +msgstr "Montant" + +#. module: account_bank_reconciliation_summary_xlsx +#: code:addons/account_bank_reconciliation_summary_xlsx/report/bank_reconciliation_xlsx.py:92 +#, python-format +msgid "Balance %s:" +msgstr "Balance %s:" + +#. module: account_bank_reconciliation_summary_xlsx +#: model:ir.model.fields,field_description:account_bank_reconciliation_summary_xlsx.field_bank_reconciliation_report_wizard_journal_ids +msgid "Bank Journals" +msgstr "Journaux de banque" + +#. module: account_bank_reconciliation_summary_xlsx +#: model:ir.actions.act_window,name:account_bank_reconciliation_summary_xlsx.bank_reconciliation_report_wizard_action +#: model:ir.ui.menu,name:account_bank_reconciliation_summary_xlsx.bank_reconciliation_report_wizard_menu +#: model:ir.ui.view,arch_db:account_bank_reconciliation_summary_xlsx.account_journal_dashboard_kanban_view +msgid "Bank Reconciliation" +msgstr "Rapprochement bancaire" + +#. module: account_bank_reconciliation_summary_xlsx +#: model:ir.ui.view,arch_db:account_bank_reconciliation_summary_xlsx.bank_reconciliation_report_wizard_form +#: model:ir.ui.view,arch_db:account_bank_reconciliation_summary_xlsx.view_bank_statement_form +msgid "Bank Reconciliation Report" +msgstr "Raport rapprochement bancaire" + +#. module: account_bank_reconciliation_summary_xlsx +#: model:ir.model,name:account_bank_reconciliation_summary_xlsx.model_bank_reconciliation_report_wizard +msgid "Bank Reconciliation Report Wizard" +msgstr "Wizard raport rapprochement bancaire" + +#. module: account_bank_reconciliation_summary_xlsx +#: model:ir.actions.report.xml,name:account_bank_reconciliation_summary_xlsx.bank_reconciliation_xlsx +msgid "Bank Reconciliation XLSX" +msgstr "XLSX rapprochement bancaire" + +#. module: account_bank_reconciliation_summary_xlsx +#: model:ir.ui.view,arch_db:account_bank_reconciliation_summary_xlsx.bank_reconciliation_report_wizard_form +msgid "Cancel" +msgstr "Annuler" + +#. module: account_bank_reconciliation_summary_xlsx +#: code:addons/account_bank_reconciliation_summary_xlsx/report/bank_reconciliation_xlsx.py:210 +#, python-format +msgid "Computed Bank Account Balance at the Bank:" +msgstr "Solde calculé du compte bancaire :" + +#. module: account_bank_reconciliation_summary_xlsx +#: code:addons/account_bank_reconciliation_summary_xlsx/report/bank_reconciliation_xlsx.py:130 +#, python-format +msgid "Counter-part" +msgstr "Contre partie" + +#. module: account_bank_reconciliation_summary_xlsx +#: model:ir.model.fields,field_description:account_bank_reconciliation_summary_xlsx.field_bank_reconciliation_report_wizard_create_uid +msgid "Created by" +msgstr "Créé par" + +#. module: account_bank_reconciliation_summary_xlsx +#: model:ir.model.fields,field_description:account_bank_reconciliation_summary_xlsx.field_bank_reconciliation_report_wizard_create_date +msgid "Created on" +msgstr "Créé le" + +#. module: account_bank_reconciliation_summary_xlsx +#: code:addons/account_bank_reconciliation_summary_xlsx/report/bank_reconciliation_xlsx.py:128 +#: code:addons/account_bank_reconciliation_summary_xlsx/report/bank_reconciliation_xlsx.py:181 +#: model:ir.model.fields,field_description:account_bank_reconciliation_summary_xlsx.field_bank_reconciliation_report_wizard_date +#, python-format +msgid "Date" +msgstr "Date " + +#. module: account_bank_reconciliation_summary_xlsx +#: code:addons/account_bank_reconciliation_summary_xlsx/report/bank_reconciliation_xlsx.py:83 +#, python-format +msgid "Date:" +msgstr "Date:" + +#. module: account_bank_reconciliation_summary_xlsx +#: model:ir.model.fields,field_description:account_bank_reconciliation_summary_xlsx.field_bank_reconciliation_report_wizard_display_name +msgid "Display Name" +msgstr "Nom affiché" + +#. module: account_bank_reconciliation_summary_xlsx +#: code:addons/account_bank_reconciliation_summary_xlsx/report/bank_reconciliation_xlsx.py:169 +#, python-format +msgid "Draft bank statement lines:" +msgstr "Lines non validées du relevé bancaire:" + +#. module: account_bank_reconciliation_summary_xlsx +#: model:ir.ui.view,arch_db:account_bank_reconciliation_summary_xlsx.bank_reconciliation_report_wizard_form +msgid "Export XLSX" +msgstr "Export XLSX" + +#. module: account_bank_reconciliation_summary_xlsx +#: model:ir.model.fields,field_description:account_bank_reconciliation_summary_xlsx.field_bank_reconciliation_report_wizard_id +msgid "ID" +msgstr "ID" + +#. module: account_bank_reconciliation_summary_xlsx +#: model:ir.model,name:account_bank_reconciliation_summary_xlsx.model_account_move_line +msgid "Journal Item" +msgstr "Écriture comptable" + +#. module: account_bank_reconciliation_summary_xlsx +#: code:addons/account_bank_reconciliation_summary_xlsx/report/bank_reconciliation_xlsx.py:113 +#, python-format +msgid "Journal items of account %s not linked to a bank statement line:" +msgstr "Ecritures comptables du compte %s not liés à une ligne de relevé bancaire :" + +#. module: account_bank_reconciliation_summary_xlsx +#: code:addons/account_bank_reconciliation_summary_xlsx/report/bank_reconciliation_xlsx.py:128 +#: code:addons/account_bank_reconciliation_summary_xlsx/report/bank_reconciliation_xlsx.py:181 +#, python-format +msgid "Label" +msgstr "Libellé" + +#. module: account_bank_reconciliation_summary_xlsx +#: model:ir.model.fields,field_description:account_bank_reconciliation_summary_xlsx.field_bank_reconciliation_report_wizard___last_update +msgid "Last Modified on" +msgstr "Dernière modification le" + +#. module: account_bank_reconciliation_summary_xlsx +#: model:ir.model.fields,field_description:account_bank_reconciliation_summary_xlsx.field_bank_reconciliation_report_wizard_write_uid +msgid "Last Updated by" +msgstr "Mis à jour par" + +#. module: account_bank_reconciliation_summary_xlsx +#: model:ir.model.fields,field_description:account_bank_reconciliation_summary_xlsx.field_bank_reconciliation_report_wizard_write_date +msgid "Last Updated on" +msgstr "Mis à jour le" + +#. module: account_bank_reconciliation_summary_xlsx +#: code:addons/account_bank_reconciliation_summary_xlsx/report/bank_reconciliation_xlsx.py:129 +#, python-format +msgid "Move Number" +msgstr "Numéro pièce comptables" + +#. module: account_bank_reconciliation_summary_xlsx +#: code:addons/account_bank_reconciliation_summary_xlsx/report/bank_reconciliation_xlsx.py:124 +#: code:addons/account_bank_reconciliation_summary_xlsx/report/bank_reconciliation_xlsx.py:177 +#, python-format +msgid "NONE" +msgstr "Rien" + +#. module: account_bank_reconciliation_summary_xlsx +#: code:addons/account_bank_reconciliation_summary_xlsx/report/bank_reconciliation_xlsx.py:215 +#, python-format +msgid "No Bank Journal" +msgstr "Pas de journal de banque" + +#. module: account_bank_reconciliation_summary_xlsx +#: code:addons/account_bank_reconciliation_summary_xlsx/report/bank_reconciliation_xlsx.py:220 +#, python-format +msgid "No bank journal selected. This report is only for bank journals." +msgstr "Pas de journal de banque sélectionné. Ce rapport est uniquement pour les journaux de banque." + +#. module: account_bank_reconciliation_summary_xlsx +#: code:addons/account_bank_reconciliation_summary_xlsx/report/bank_reconciliation_xlsx.py:128 +#: code:addons/account_bank_reconciliation_summary_xlsx/report/bank_reconciliation_xlsx.py:182 +#, python-format +msgid "Partner" +msgstr "Partenaire" + +#. module: account_bank_reconciliation_summary_xlsx +#: code:addons/account_bank_reconciliation_summary_xlsx/report/bank_reconciliation_xlsx.py:128 +#: code:addons/account_bank_reconciliation_summary_xlsx/report/bank_reconciliation_xlsx.py:181 +#, python-format +msgid "Ref." +msgstr "Ref." + +#. module: account_bank_reconciliation_summary_xlsx +#: code:addons/account_bank_reconciliation_summary_xlsx/report/bank_reconciliation_xlsx.py:129 +#: model:ir.model.fields,field_description:account_bank_reconciliation_summary_xlsx.field_account_move_line_statement_line_date +#, python-format +msgid "Statement Line Date" +msgstr "Date ligne relevé" + +#. module: account_bank_reconciliation_summary_xlsx +#: code:addons/account_bank_reconciliation_summary_xlsx/report/bank_reconciliation_xlsx.py:182 +#, python-format +msgid "Statement Ref." +msgstr "Ref. relevé" + diff --git a/account_bank_reconciliation_summary_xlsx/report/bank_reconciliation_xlsx.py b/account_bank_reconciliation_summary_xlsx/report/bank_reconciliation_xlsx.py index b9ca49cd..2e1fcd2d 100644 --- a/account_bank_reconciliation_summary_xlsx/report/bank_reconciliation_xlsx.py +++ b/account_bank_reconciliation_summary_xlsx/report/bank_reconciliation_xlsx.py @@ -198,7 +198,7 @@ class BankReconciliationXlsx(ReportXlsx): row, 3, bline.partner_id.display_name or '', regular) sheet.write(row, 4, bline.amount, regular_currency) sheet.write( - row, 5, bline.statement_id.name or '', + row, 5, bline.statement_id.display_name or '', regular_currency) formula += '+SUM(E%d:E%d)' % (b_start_row + 1, b_end_row + 1) diff --git a/account_bank_reconciliation_summary_xlsx/wizard/bank_reconciliation_report_wizard.py b/account_bank_reconciliation_summary_xlsx/wizard/bank_reconciliation_report_wizard.py index 9c887bd5..61040e2b 100644 --- a/account_bank_reconciliation_summary_xlsx/wizard/bank_reconciliation_report_wizard.py +++ b/account_bank_reconciliation_summary_xlsx/wizard/bank_reconciliation_report_wizard.py @@ -13,7 +13,9 @@ class BankReconciliationReportWizard(models.TransientModel): def _default_journal_ids(self): journals = self.env['account.journal'].search([ ('type', '=', 'bank'), - ('company_id', '=', self.env.user.company_id.id)]) + ('bank_account_id', '!=', False), + ('company_id', '=', self.env.user.company_id.id), + ]) return journals date = fields.Date( From 5b87a998bdef319f086439128f45b3164fe01c75 Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Tue, 15 Jan 2019 17:13:03 +0100 Subject: [PATCH 10/14] Add company name in title of the XLSX report --- .../report/bank_reconciliation_xlsx.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/account_bank_reconciliation_summary_xlsx/report/bank_reconciliation_xlsx.py b/account_bank_reconciliation_summary_xlsx/report/bank_reconciliation_xlsx.py index 2e1fcd2d..635de784 100644 --- a/account_bank_reconciliation_summary_xlsx/report/bank_reconciliation_xlsx.py +++ b/account_bank_reconciliation_summary_xlsx/report/bank_reconciliation_xlsx.py @@ -67,7 +67,9 @@ class BankReconciliationXlsx(ReportXlsx): sheet = workbook.add_worksheet(o.code or o.name) sheet.write( - 0, 0, _('%s - Bank Reconciliation') % o.display_name, + 0, 0, + _('%s - %s - Bank Reconciliation') % ( + o.company_id.name, o.display_name), doc_title) sheet.set_row(0, 26) sheet.set_row(1, 25) From 78e9c72fdbbc6fcd4eb39b8f14877d9da6c09f3e Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Sat, 2 Mar 2019 15:26:05 +0100 Subject: [PATCH 11/14] Fix FR translation --- .../i18n/fr.po | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/account_bank_reconciliation_summary_xlsx/i18n/fr.po b/account_bank_reconciliation_summary_xlsx/i18n/fr.po index 2cfe1d92..e745e11e 100644 --- a/account_bank_reconciliation_summary_xlsx/i18n/fr.po +++ b/account_bank_reconciliation_summary_xlsx/i18n/fr.po @@ -24,7 +24,7 @@ msgstr "%s - Rapprochement bancaire" #. module: account_bank_reconciliation_summary_xlsx #: model:ir.ui.view,arch_db:account_bank_reconciliation_summary_xlsx.account_journal_dashboard_kanban_view msgid "Report" -msgstr "Raport" +msgstr "Rapport" #. module: account_bank_reconciliation_summary_xlsx #: code:addons/account_bank_reconciliation_summary_xlsx/report/bank_reconciliation_xlsx.py:129 @@ -55,7 +55,7 @@ msgstr "Rapprochement bancaire" #: model:ir.ui.view,arch_db:account_bank_reconciliation_summary_xlsx.bank_reconciliation_report_wizard_form #: model:ir.ui.view,arch_db:account_bank_reconciliation_summary_xlsx.view_bank_statement_form msgid "Bank Reconciliation Report" -msgstr "Raport rapprochement bancaire" +msgstr "Rapport rapprochement bancaire" #. module: account_bank_reconciliation_summary_xlsx #: model:ir.model,name:account_bank_reconciliation_summary_xlsx.model_bank_reconciliation_report_wizard @@ -65,7 +65,7 @@ msgstr "Wizard raport rapprochement bancaire" #. module: account_bank_reconciliation_summary_xlsx #: model:ir.actions.report.xml,name:account_bank_reconciliation_summary_xlsx.bank_reconciliation_xlsx msgid "Bank Reconciliation XLSX" -msgstr "XLSX rapprochement bancaire" +msgstr "Rapprochement bancaire XLSX" #. module: account_bank_reconciliation_summary_xlsx #: model:ir.ui.view,arch_db:account_bank_reconciliation_summary_xlsx.bank_reconciliation_report_wizard_form @@ -76,7 +76,7 @@ msgstr "Annuler" #: code:addons/account_bank_reconciliation_summary_xlsx/report/bank_reconciliation_xlsx.py:210 #, python-format msgid "Computed Bank Account Balance at the Bank:" -msgstr "Solde calculé du compte bancaire :" +msgstr "Solde théorique du compte bancaire :" #. module: account_bank_reconciliation_summary_xlsx #: code:addons/account_bank_reconciliation_summary_xlsx/report/bank_reconciliation_xlsx.py:130 @@ -106,7 +106,7 @@ msgstr "Date " #: code:addons/account_bank_reconciliation_summary_xlsx/report/bank_reconciliation_xlsx.py:83 #, python-format msgid "Date:" -msgstr "Date:" +msgstr "Date :" #. module: account_bank_reconciliation_summary_xlsx #: model:ir.model.fields,field_description:account_bank_reconciliation_summary_xlsx.field_bank_reconciliation_report_wizard_display_name @@ -117,7 +117,7 @@ msgstr "Nom affiché" #: code:addons/account_bank_reconciliation_summary_xlsx/report/bank_reconciliation_xlsx.py:169 #, python-format msgid "Draft bank statement lines:" -msgstr "Lines non validées du relevé bancaire:" +msgstr "Lignes non validées du relevé bancaire :" #. module: account_bank_reconciliation_summary_xlsx #: model:ir.ui.view,arch_db:account_bank_reconciliation_summary_xlsx.bank_reconciliation_report_wizard_form @@ -138,7 +138,7 @@ msgstr "Écriture comptable" #: code:addons/account_bank_reconciliation_summary_xlsx/report/bank_reconciliation_xlsx.py:113 #, python-format msgid "Journal items of account %s not linked to a bank statement line:" -msgstr "Ecritures comptables du compte %s not liés à une ligne de relevé bancaire :" +msgstr "Ecritures comptables du compte %s non liées à une ligne de relevé bancaire :" #. module: account_bank_reconciliation_summary_xlsx #: code:addons/account_bank_reconciliation_summary_xlsx/report/bank_reconciliation_xlsx.py:128 @@ -166,7 +166,7 @@ msgstr "Mis à jour le" #: code:addons/account_bank_reconciliation_summary_xlsx/report/bank_reconciliation_xlsx.py:129 #, python-format msgid "Move Number" -msgstr "Numéro pièce comptables" +msgstr "Numéro de pièce" #. module: account_bank_reconciliation_summary_xlsx #: code:addons/account_bank_reconciliation_summary_xlsx/report/bank_reconciliation_xlsx.py:124 From dfee27a56ce9b2511db4d7b6ed76c2ebcf606dbe Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Sat, 2 Mar 2019 18:31:32 +0100 Subject: [PATCH 12/14] [MIG] account_bank_reconciliation_summary_xlsx from v10 to v12 --- .../__init__.py | 2 - .../__manifest__.py | 12 +- .../models/__init__.py | 2 - .../models/account_move_line.py | 6 +- .../readme/CONFIGURE.rst | 1 + .../readme/CONTRIBUTORS.rst | 1 + .../readme/DESCRIPTION.rst | 8 + .../readme/USAGE.rst | 5 + .../report/__init__.py | 2 - .../report/bank_reconciliation_xlsx.py | 155 ++++++++++-------- .../report/report.xml | 5 +- .../views/account_bank_statement.xml | 3 +- .../views/account_journal.xml | 5 +- .../views/account_move_line.xml | 5 +- .../wizard/__init__.py | 2 - .../bank_reconciliation_report_wizard.py | 21 +-- ...bank_reconciliation_report_wizard_view.xml | 11 +- 17 files changed, 139 insertions(+), 107 deletions(-) create mode 100644 account_bank_reconciliation_summary_xlsx/readme/CONFIGURE.rst create mode 100644 account_bank_reconciliation_summary_xlsx/readme/CONTRIBUTORS.rst create mode 100644 account_bank_reconciliation_summary_xlsx/readme/DESCRIPTION.rst create mode 100644 account_bank_reconciliation_summary_xlsx/readme/USAGE.rst diff --git a/account_bank_reconciliation_summary_xlsx/__init__.py b/account_bank_reconciliation_summary_xlsx/__init__.py index de9509a6..7660e7bf 100644 --- a/account_bank_reconciliation_summary_xlsx/__init__.py +++ b/account_bank_reconciliation_summary_xlsx/__init__.py @@ -1,5 +1,3 @@ -# -*- coding: utf-8 -*- - from . import models from . import report from . import wizard diff --git a/account_bank_reconciliation_summary_xlsx/__manifest__.py b/account_bank_reconciliation_summary_xlsx/__manifest__.py index de9c9a43..c81f9948 100644 --- a/account_bank_reconciliation_summary_xlsx/__manifest__.py +++ b/account_bank_reconciliation_summary_xlsx/__manifest__.py @@ -1,15 +1,15 @@ -# -*- coding: utf-8 -*- -# © 2017 Akretion (Alexis de Lattre ) +# Copyright 2017-2019 Akretion France (http://www.akretion.com/) +# @author: Alexis de Lattre # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). { 'name': 'Bank Reconciliation Report', - 'version': '10.0.1.0.0', + 'version': '12.0.1.0.0', 'license': 'AGPL-3', 'author': "Akretion,Odoo Community Association (OCA)", - 'website': 'http://www.akretion.com', - 'summary': 'Adds an XLSX report to help on bank reconciliation', - 'depends': ['account_financial_report_qweb', 'report_xlsx'], + 'website': 'https://github.com/OCA/account-financial-reporting', + 'summary': 'XLSX report to help on bank reconciliation', + 'depends': ['account_financial_report', 'report_xlsx'], 'data': [ 'report/report.xml', 'wizard/bank_reconciliation_report_wizard_view.xml', diff --git a/account_bank_reconciliation_summary_xlsx/models/__init__.py b/account_bank_reconciliation_summary_xlsx/models/__init__.py index 0c1006db..8795b3be 100644 --- a/account_bank_reconciliation_summary_xlsx/models/__init__.py +++ b/account_bank_reconciliation_summary_xlsx/models/__init__.py @@ -1,3 +1 @@ -# -*- coding: utf-8 -*- - from . import account_move_line diff --git a/account_bank_reconciliation_summary_xlsx/models/account_move_line.py b/account_bank_reconciliation_summary_xlsx/models/account_move_line.py index 21727012..a9f2605c 100644 --- a/account_bank_reconciliation_summary_xlsx/models/account_move_line.py +++ b/account_bank_reconciliation_summary_xlsx/models/account_move_line.py @@ -1,5 +1,5 @@ -# -*- coding: utf-8 -*- -# © 2017 Akretion (Alexis de Lattre ) +# Copyright 2017-2019 Akretion France (http://www.akretion.com/) +# @author: Alexis de Lattre # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). from odoo import fields, models @@ -10,4 +10,4 @@ class AccountMoveLine(models.Model): statement_line_date = fields.Date( string='Statement Line Date', - related='move_id.statement_line_id.date', store=True, readonly=True) + related='statement_line_id.date', store=True) diff --git a/account_bank_reconciliation_summary_xlsx/readme/CONFIGURE.rst b/account_bank_reconciliation_summary_xlsx/readme/CONFIGURE.rst new file mode 100644 index 00000000..8b3e6561 --- /dev/null +++ b/account_bank_reconciliation_summary_xlsx/readme/CONFIGURE.rst @@ -0,0 +1 @@ +This module doesn't require any configuration. diff --git a/account_bank_reconciliation_summary_xlsx/readme/CONTRIBUTORS.rst b/account_bank_reconciliation_summary_xlsx/readme/CONTRIBUTORS.rst new file mode 100644 index 00000000..ff65d68c --- /dev/null +++ b/account_bank_reconciliation_summary_xlsx/readme/CONTRIBUTORS.rst @@ -0,0 +1 @@ +* Alexis de Lattre diff --git a/account_bank_reconciliation_summary_xlsx/readme/DESCRIPTION.rst b/account_bank_reconciliation_summary_xlsx/readme/DESCRIPTION.rst new file mode 100644 index 00000000..d75d9ec3 --- /dev/null +++ b/account_bank_reconciliation_summary_xlsx/readme/DESCRIPTION.rst @@ -0,0 +1,8 @@ +This module adds a Bank Reconciliation Report in Odoo in XLSX format. For each bank journal, the report displays: + +1. The balance of the bank account in the accounting, +2. The list of journal items of the bank account not linked to any bank statement lines, +3. The list of draft bank statement lines not linked to any journal items, +4. The computed balance of the bank account at the bank. + +The last field (computed balance of the bank account at the bank) must be compared to the real bank account balance at the bank. If there is a difference, you need to find the error in the accounting. The field *Computed balance of the bank account at the bank* is a formula, so you can easily change its computation to try to find the difference with the real bank account balance at the bank. diff --git a/account_bank_reconciliation_summary_xlsx/readme/USAGE.rst b/account_bank_reconciliation_summary_xlsx/readme/USAGE.rst new file mode 100644 index 00000000..49384754 --- /dev/null +++ b/account_bank_reconciliation_summary_xlsx/readme/USAGE.rst @@ -0,0 +1,5 @@ +You can launch the Bank Reconciliation Report wizard from: + +* the menu *Invoicing > Reporting > OCA accounting reports > Bank Reconciliation*, +* the form view of a bank statement: click on the button *Bank Reconciliation Report*, +* the invoicing dashboard: on a bank journal, click on the options, then select *Bank Reconciliation*. diff --git a/account_bank_reconciliation_summary_xlsx/report/__init__.py b/account_bank_reconciliation_summary_xlsx/report/__init__.py index ce3ccb2c..c23e36d8 100644 --- a/account_bank_reconciliation_summary_xlsx/report/__init__.py +++ b/account_bank_reconciliation_summary_xlsx/report/__init__.py @@ -1,3 +1 @@ -# -*- coding: utf-8 -*- - from . import bank_reconciliation_xlsx diff --git a/account_bank_reconciliation_summary_xlsx/report/bank_reconciliation_xlsx.py b/account_bank_reconciliation_summary_xlsx/report/bank_reconciliation_xlsx.py index 635de784..c415b43d 100644 --- a/account_bank_reconciliation_summary_xlsx/report/bank_reconciliation_xlsx.py +++ b/account_bank_reconciliation_summary_xlsx/report/bank_reconciliation_xlsx.py @@ -1,14 +1,76 @@ -# -*- coding: utf-8 -*- -# © 2017 Akretion France (Alexis de Lattre ) +# Copyright 2017-2019 Akretion France (http://www.akretion.com/) +# @author: Alexis de Lattre # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -from odoo.addons.report_xlsx.report.report_xlsx import ReportXlsx -from odoo import fields, _ -from odoo.tools import DEFAULT_SERVER_DATE_FORMAT -from datetime import datetime +from odoo import _, fields, models -class BankReconciliationXlsx(ReportXlsx): +class BankReconciliationXlsx(models.AbstractModel): + _name = 'report.bank.reconciliation.xlsx' + _inherit = 'report.report_xlsx.abstract' + + def _compute_account_balance(self, journal, date): + bank_account = journal.default_debit_account_id + amount_field = 'balance' + # TODO: add support for bank accounts in foreign currency + # if not o.currency_id else 'amount_currency' + query = """ + SELECT sum(%s) FROM account_move_line + WHERE account_id=%%s AND date <= %%s""" % (amount_field, ) + self.env.cr.execute(query, (bank_account.id, date)) + query_results = self.env.cr.dictfetchall() + if query_results: + account_bal = query_results[0].get('sum') or 0.0 + else: + account_bal = 0.0 + return account_bal + + def _prepare_move_lines(self, journal, date): + bank_account = journal.default_debit_account_id + mlines = self.env['account.move.line'].search([ + ('account_id', '=', bank_account.id), + ('journal_id', '=', journal.id), # to avoid initial line + ('date', '<=', date), + '|', ('statement_line_date', '=', False), + ('statement_line_date', '>', date)]) + res = [] + for mline in mlines: + move = mline.move_id + cpart = [] + for line in move.line_ids: + if ( + line.account_id != bank_account and + line.account_id.code not in cpart): + cpart.append(line.account_id.code) + counterpart = ' ,'.join(cpart) + res.append({ + 'date': mline.date, + 'label': mline.name, + 'ref': mline.ref or '', + 'partner': mline.partner_id.display_name or '', + 'amount': mline.balance, + 'statement_line_date': mline.statement_line_date or '', + 'move_number': move.name, + 'counterpart': counterpart, + }) + return res + + def _prepare_draft_statement_lines(self, journal, date): + blines = self.env['account.bank.statement.line'].search([ + ('journal_entry_ids', '=', False), + ('journal_id', '=', journal.id), + ('date', '<=', date)]) + res = [] + for bline in blines: + res.append({ + 'date': bline.date, + 'label': bline.name, + 'ref': bline.ref or '', + 'partner': bline.partner_id.display_name or '', + 'amount': bline.amount, + 'statement_ref': bline.statement_id.display_name, + }) + return res def generate_xlsx_report(self, workbook, data, wizard): date = wizard.date @@ -92,18 +154,7 @@ class BankReconciliationXlsx(ReportXlsx): sheet.write( row, 3, _('Balance %s:') % bank_account.code, title_right) - amount_field = 'balance' - # TODO: add support for bank accounts in foreign currency - # if not o.currency_id else 'amount_currency' - query = """ - SELECT sum(%s) FROM account_move_line - WHERE account_id=%%s AND date <= %%s""" % (amount_field, ) - self.env.cr.execute(query, (bank_account.id, date)) - query_results = self.env.cr.dictfetchall() - if query_results: - account_bal = query_results[0].get('sum') or 0.0 - else: - account_bal = 0.0 + account_bal = self._compute_account_balance(o, date) sheet.write(row, 4, account_bal, regular_currency_bg) bank_bal = account_bal @@ -116,12 +167,7 @@ class BankReconciliationXlsx(ReportXlsx): 'Journal items of account %s not linked to a bank ' 'statement line:') % bank_account.code, label_bold) - mlines = self.env['account.move.line'].search([ - ('account_id', '=', bank_account.id), - ('journal_id', '=', o.id), # to avoid initial line - ('date', '<=', date), - '|', ('statement_line_date', '=', False), - ('statement_line_date', '>', date)]) + mlines = self._prepare_move_lines(o, date) if not mlines: sheet.write(row, 4, _('NONE'), none) else: @@ -138,30 +184,16 @@ class BankReconciliationXlsx(ReportXlsx): for mline in mlines: row += 1 m_end_row = row - move = mline.move_id - bank_bal -= mline.balance - date_dt = fields.Date.from_string(mline.date) - sheet.write(row, 0, date_dt, regular_date) - sheet.write(row, 1, mline.name, regular) - sheet.write(row, 2, mline.ref or '', regular) + bank_bal -= mline['amount'] + sheet.write(row, 0, mline['date'], regular_date) + sheet.write(row, 1, mline['label'], regular) + sheet.write(row, 2, mline['ref'], regular) + sheet.write(row, 3, mline['partner'], regular) + sheet.write(row, 4, mline['amount'], regular_currency) sheet.write( - row, 3, mline.partner_id.display_name or '', regular) - sheet.write(row, 4, mline.balance, regular_currency) - if mline.statement_line_date: - stl_date_dt = fields.Date.from_string( - mline.statement_line_date) - else: - stl_date_dt = '' - sheet.write(row, 5, stl_date_dt, regular_date) - sheet.write(row, 6, move.name, regular) - # counter-part accounts - cpart = [] - for line in move.line_ids: - if ( - line.account_id != bank_account and - line.account_id.code not in cpart): - cpart.append(line.account_id.code) - sheet.write(row, 7, ' ,'.join(cpart), regular) + row, 5, mline['statement_line_date'], regular_date) + sheet.write(row, 6, mline['move_number'], regular) + sheet.write(row, 7, mline['counterpart'], regular) formula += '-SUM(E%d:E%d)' % (m_start_row + 1, m_end_row + 1) @@ -171,10 +203,7 @@ class BankReconciliationXlsx(ReportXlsx): row, 0, _( 'Draft bank statement lines:'), label_bold) - blines = self.env['account.bank.statement.line'].search([ - ('journal_entry_ids', '=', False), - ('journal_id', '=', o.id), - ('date', '<=', date)]) + blines = self._prepare_draft_statement_lines(o, date) if not blines: sheet.write(row, 4, _('NONE'), none) else: @@ -190,18 +219,14 @@ class BankReconciliationXlsx(ReportXlsx): for bline in blines: row += 1 b_end_row = row - bank_bal += bline.amount - date_dt = datetime.strptime( - bline.date, DEFAULT_SERVER_DATE_FORMAT) - sheet.write(row, 0, date_dt, regular_date) - sheet.write(row, 1, bline.name, regular) - sheet.write(row, 2, bline.ref or '', regular) - sheet.write( - row, 3, bline.partner_id.display_name or '', regular) - sheet.write(row, 4, bline.amount, regular_currency) + bank_bal += bline['amount'] + sheet.write(row, 0, bline['date'], regular_date) + sheet.write(row, 1, bline['label'], regular) + sheet.write(row, 2, bline['ref'], regular) + sheet.write(row, 3, bline['partner'], regular) + sheet.write(row, 4, bline['amount'], regular_currency) sheet.write( - row, 5, bline.statement_id.display_name or '', - regular_currency) + row, 5, bline['statement_ref'], regular_currency) formula += '+SUM(E%d:E%d)' % (b_start_row + 1, b_end_row + 1) # 4) Theoric bank account balance at the bank @@ -222,7 +247,3 @@ class BankReconciliationXlsx(ReportXlsx): 0, 0, _( "No bank journal selected. " "This report is only for bank journals."), warn_msg) - - -BankReconciliationXlsx( - 'report.bank.reconciliation.xlsx', 'bank.reconciliation.report.wizard') diff --git a/account_bank_reconciliation_summary_xlsx/report/report.xml b/account_bank_reconciliation_summary_xlsx/report/report.xml index 8a855b44..0ad61e12 100644 --- a/account_bank_reconciliation_summary_xlsx/report/report.xml +++ b/account_bank_reconciliation_summary_xlsx/report/report.xml @@ -1,6 +1,7 @@ @@ -13,6 +14,8 @@ report_type="xlsx" name="bank.reconciliation.xlsx" file="bank.reconciliation.xlsx" + print_report_name="'bank_reconciliation-%s' % (object.date)" /> + diff --git a/account_bank_reconciliation_summary_xlsx/views/account_bank_statement.xml b/account_bank_reconciliation_summary_xlsx/views/account_bank_statement.xml index 63a36f61..6b0b087b 100644 --- a/account_bank_reconciliation_summary_xlsx/views/account_bank_statement.xml +++ b/account_bank_reconciliation_summary_xlsx/views/account_bank_statement.xml @@ -1,6 +1,7 @@ diff --git a/account_bank_reconciliation_summary_xlsx/views/account_journal.xml b/account_bank_reconciliation_summary_xlsx/views/account_journal.xml index 35c9d999..4f85740c 100644 --- a/account_bank_reconciliation_summary_xlsx/views/account_journal.xml +++ b/account_bank_reconciliation_summary_xlsx/views/account_journal.xml @@ -1,6 +1,7 @@ @@ -13,7 +14,7 @@ -
+
Report
diff --git a/account_bank_reconciliation_summary_xlsx/views/account_move_line.xml b/account_bank_reconciliation_summary_xlsx/views/account_move_line.xml index 7e03af6c..0bddde15 100644 --- a/account_bank_reconciliation_summary_xlsx/views/account_move_line.xml +++ b/account_bank_reconciliation_summary_xlsx/views/account_move_line.xml @@ -1,6 +1,7 @@ @@ -8,7 +9,7 @@ - bank_rec_summarry.account_move_line_form + bank_rec_summary.account_move_line_form account.move.line diff --git a/account_bank_reconciliation_summary_xlsx/wizard/__init__.py b/account_bank_reconciliation_summary_xlsx/wizard/__init__.py index 02696cfe..4ca3cb46 100644 --- a/account_bank_reconciliation_summary_xlsx/wizard/__init__.py +++ b/account_bank_reconciliation_summary_xlsx/wizard/__init__.py @@ -1,3 +1 @@ -# -*- coding: utf-8 -*- - from . import bank_reconciliation_report_wizard diff --git a/account_bank_reconciliation_summary_xlsx/wizard/bank_reconciliation_report_wizard.py b/account_bank_reconciliation_summary_xlsx/wizard/bank_reconciliation_report_wizard.py index 61040e2b..e93752be 100644 --- a/account_bank_reconciliation_summary_xlsx/wizard/bank_reconciliation_report_wizard.py +++ b/account_bank_reconciliation_summary_xlsx/wizard/bank_reconciliation_report_wizard.py @@ -1,5 +1,5 @@ -# -*- coding: utf-8 -*- -# © 2017 Akretion (Alexis de Lattre ) +# Copyright 2017-2019 Akretion France (http://www.akretion.com/) +# @author: Alexis de Lattre # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). from odoo import api, fields, models @@ -24,18 +24,11 @@ class BankReconciliationReportWizard(models.TransientModel): journal_ids = fields.Many2many( 'account.journal', string='Bank Journals', domain=[('type', '=', 'bank')], required=True, - default=_default_journal_ids) + default=lambda self: self._default_journal_ids()) def open_xlsx(self): - action = { - 'type': 'ir.actions.report.xml', - 'report_name': 'bank.reconciliation.xlsx', - 'datas': { - 'model': self._name, - 'ids': self.ids, - 'journal_ids': self.journal_ids.ids, - 'date': self.date, - }, - 'context': self._context, - } + report = self.env.ref( + 'account_bank_reconciliation_summary_xlsx.' + 'bank_reconciliation_xlsx') + action = report.report_action(self) return action diff --git a/account_bank_reconciliation_summary_xlsx/wizard/bank_reconciliation_report_wizard_view.xml b/account_bank_reconciliation_summary_xlsx/wizard/bank_reconciliation_report_wizard_view.xml index 13227916..ebcd4db7 100644 --- a/account_bank_reconciliation_summary_xlsx/wizard/bank_reconciliation_report_wizard_view.xml +++ b/account_bank_reconciliation_summary_xlsx/wizard/bank_reconciliation_report_wizard_view.xml @@ -1,6 +1,7 @@ @@ -18,7 +19,7 @@
@@ -31,7 +32,11 @@ new
- + From 87ee306db55c235dfc8679550d4c330c186085fe Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Sun, 7 Jun 2020 15:52:43 +0200 Subject: [PATCH 13/14] [MIG] account_bank_reconciliation_summary_xlsx to v13 --- account_bank_reconciliation_summary_xlsx/__manifest__.py | 4 ++-- .../models/account_move_line.py | 2 +- .../report/bank_reconciliation_xlsx.py | 3 ++- account_bank_reconciliation_summary_xlsx/report/report.xml | 2 +- .../views/account_bank_statement.xml | 2 +- .../views/account_journal.xml | 2 +- .../views/account_move_line.xml | 2 +- .../wizard/bank_reconciliation_report_wizard.py | 2 +- .../wizard/bank_reconciliation_report_wizard_view.xml | 2 +- 9 files changed, 11 insertions(+), 10 deletions(-) diff --git a/account_bank_reconciliation_summary_xlsx/__manifest__.py b/account_bank_reconciliation_summary_xlsx/__manifest__.py index c81f9948..69f71bed 100644 --- a/account_bank_reconciliation_summary_xlsx/__manifest__.py +++ b/account_bank_reconciliation_summary_xlsx/__manifest__.py @@ -1,10 +1,10 @@ -# Copyright 2017-2019 Akretion France (http://www.akretion.com/) +# Copyright 2017-2020 Akretion France (http://www.akretion.com/) # @author: Alexis de Lattre # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). { 'name': 'Bank Reconciliation Report', - 'version': '12.0.1.0.0', + 'version': '13.0.1.0.0', 'license': 'AGPL-3', 'author': "Akretion,Odoo Community Association (OCA)", 'website': 'https://github.com/OCA/account-financial-reporting', diff --git a/account_bank_reconciliation_summary_xlsx/models/account_move_line.py b/account_bank_reconciliation_summary_xlsx/models/account_move_line.py index a9f2605c..32268385 100644 --- a/account_bank_reconciliation_summary_xlsx/models/account_move_line.py +++ b/account_bank_reconciliation_summary_xlsx/models/account_move_line.py @@ -1,4 +1,4 @@ -# Copyright 2017-2019 Akretion France (http://www.akretion.com/) +# Copyright 2017-2020 Akretion France (http://www.akretion.com/) # @author: Alexis de Lattre # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). diff --git a/account_bank_reconciliation_summary_xlsx/report/bank_reconciliation_xlsx.py b/account_bank_reconciliation_summary_xlsx/report/bank_reconciliation_xlsx.py index c415b43d..833cdb99 100644 --- a/account_bank_reconciliation_summary_xlsx/report/bank_reconciliation_xlsx.py +++ b/account_bank_reconciliation_summary_xlsx/report/bank_reconciliation_xlsx.py @@ -1,4 +1,4 @@ -# Copyright 2017-2019 Akretion France (http://www.akretion.com/) +# Copyright 2017-2020 Akretion France (http://www.akretion.com/) # @author: Alexis de Lattre # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). @@ -7,6 +7,7 @@ from odoo import _, fields, models class BankReconciliationXlsx(models.AbstractModel): _name = 'report.bank.reconciliation.xlsx' + _description = 'Bank Reconciliation XLSX Report' _inherit = 'report.report_xlsx.abstract' def _compute_account_balance(self, journal, date): diff --git a/account_bank_reconciliation_summary_xlsx/report/report.xml b/account_bank_reconciliation_summary_xlsx/report/report.xml index 0ad61e12..c7a9ce25 100644 --- a/account_bank_reconciliation_summary_xlsx/report/report.xml +++ b/account_bank_reconciliation_summary_xlsx/report/report.xml @@ -1,6 +1,6 @@ diff --git a/account_bank_reconciliation_summary_xlsx/views/account_bank_statement.xml b/account_bank_reconciliation_summary_xlsx/views/account_bank_statement.xml index 6b0b087b..9b57a3ae 100644 --- a/account_bank_reconciliation_summary_xlsx/views/account_bank_statement.xml +++ b/account_bank_reconciliation_summary_xlsx/views/account_bank_statement.xml @@ -1,6 +1,6 @@ diff --git a/account_bank_reconciliation_summary_xlsx/views/account_journal.xml b/account_bank_reconciliation_summary_xlsx/views/account_journal.xml index 4f85740c..5340adb2 100644 --- a/account_bank_reconciliation_summary_xlsx/views/account_journal.xml +++ b/account_bank_reconciliation_summary_xlsx/views/account_journal.xml @@ -1,6 +1,6 @@ diff --git a/account_bank_reconciliation_summary_xlsx/views/account_move_line.xml b/account_bank_reconciliation_summary_xlsx/views/account_move_line.xml index 0bddde15..0afd4b68 100644 --- a/account_bank_reconciliation_summary_xlsx/views/account_move_line.xml +++ b/account_bank_reconciliation_summary_xlsx/views/account_move_line.xml @@ -1,6 +1,6 @@ diff --git a/account_bank_reconciliation_summary_xlsx/wizard/bank_reconciliation_report_wizard.py b/account_bank_reconciliation_summary_xlsx/wizard/bank_reconciliation_report_wizard.py index e93752be..591d0c32 100644 --- a/account_bank_reconciliation_summary_xlsx/wizard/bank_reconciliation_report_wizard.py +++ b/account_bank_reconciliation_summary_xlsx/wizard/bank_reconciliation_report_wizard.py @@ -1,4 +1,4 @@ -# Copyright 2017-2019 Akretion France (http://www.akretion.com/) +# Copyright 2017-2020 Akretion France (http://www.akretion.com/) # @author: Alexis de Lattre # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). diff --git a/account_bank_reconciliation_summary_xlsx/wizard/bank_reconciliation_report_wizard_view.xml b/account_bank_reconciliation_summary_xlsx/wizard/bank_reconciliation_report_wizard_view.xml index ebcd4db7..692c2c46 100644 --- a/account_bank_reconciliation_summary_xlsx/wizard/bank_reconciliation_report_wizard_view.xml +++ b/account_bank_reconciliation_summary_xlsx/wizard/bank_reconciliation_report_wizard_view.xml @@ -1,6 +1,6 @@ From 1e9b385cd0a7c133cb017abc015e51e135865889 Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Sun, 7 Jun 2020 15:58:33 +0200 Subject: [PATCH 14/14] account_bank_reconciliation_summary_xlsx: black, isort, etc. --- .../__manifest__.py | 30 +- .../models/account_move_line.py | 6 +- .../report/bank_reconciliation_xlsx.py | 298 ++++++++++-------- .../report/report.xml | 23 +- .../views/account_bank_statement.xml | 33 +- .../views/account_journal.xml | 48 +-- .../views/account_move_line.xml | 25 +- .../bank_reconciliation_report_wizard.py | 29 +- ...bank_reconciliation_report_wizard_view.xml | 64 ++-- .../account_bank_reconciliation_summary_xlsx | 1 + .../setup.py | 6 + 11 files changed, 304 insertions(+), 259 deletions(-) create mode 120000 setup/account_bank_reconciliation_summary_xlsx/odoo/addons/account_bank_reconciliation_summary_xlsx create mode 100644 setup/account_bank_reconciliation_summary_xlsx/setup.py diff --git a/account_bank_reconciliation_summary_xlsx/__manifest__.py b/account_bank_reconciliation_summary_xlsx/__manifest__.py index 69f71bed..1534d503 100644 --- a/account_bank_reconciliation_summary_xlsx/__manifest__.py +++ b/account_bank_reconciliation_summary_xlsx/__manifest__.py @@ -3,19 +3,19 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). { - 'name': 'Bank Reconciliation Report', - 'version': '13.0.1.0.0', - 'license': 'AGPL-3', - 'author': "Akretion,Odoo Community Association (OCA)", - 'website': 'https://github.com/OCA/account-financial-reporting', - 'summary': 'XLSX report to help on bank reconciliation', - 'depends': ['account_financial_report', 'report_xlsx'], - 'data': [ - 'report/report.xml', - 'wizard/bank_reconciliation_report_wizard_view.xml', - 'views/account_bank_statement.xml', - 'views/account_move_line.xml', - 'views/account_journal.xml', - ], - 'installable': True, + "name": "Bank Reconciliation Report", + "version": "13.0.1.0.0", + "license": "AGPL-3", + "author": "Akretion,Odoo Community Association (OCA)", + "website": "https://github.com/OCA/account-financial-reporting", + "summary": "XLSX report to help on bank reconciliation", + "depends": ["account_financial_report", "report_xlsx"], + "data": [ + "report/report.xml", + "wizard/bank_reconciliation_report_wizard_view.xml", + "views/account_bank_statement.xml", + "views/account_move_line.xml", + "views/account_journal.xml", + ], + "installable": True, } diff --git a/account_bank_reconciliation_summary_xlsx/models/account_move_line.py b/account_bank_reconciliation_summary_xlsx/models/account_move_line.py index 32268385..a38b26e7 100644 --- a/account_bank_reconciliation_summary_xlsx/models/account_move_line.py +++ b/account_bank_reconciliation_summary_xlsx/models/account_move_line.py @@ -6,8 +6,8 @@ from odoo import fields, models class AccountMoveLine(models.Model): - _inherit = 'account.move.line' + _inherit = "account.move.line" statement_line_date = fields.Date( - string='Statement Line Date', - related='statement_line_id.date', store=True) + string="Statement Line Date", related="statement_line_id.date", store=True + ) diff --git a/account_bank_reconciliation_summary_xlsx/report/bank_reconciliation_xlsx.py b/account_bank_reconciliation_summary_xlsx/report/bank_reconciliation_xlsx.py index 833cdb99..acf24d1a 100644 --- a/account_bank_reconciliation_summary_xlsx/report/bank_reconciliation_xlsx.py +++ b/account_bank_reconciliation_summary_xlsx/report/bank_reconciliation_xlsx.py @@ -6,71 +6,82 @@ from odoo import _, fields, models class BankReconciliationXlsx(models.AbstractModel): - _name = 'report.bank.reconciliation.xlsx' - _description = 'Bank Reconciliation XLSX Report' - _inherit = 'report.report_xlsx.abstract' + _name = "report.bank.reconciliation.xlsx" + _description = "Bank Reconciliation XLSX Report" + _inherit = "report.report_xlsx.abstract" def _compute_account_balance(self, journal, date): bank_account = journal.default_debit_account_id - amount_field = 'balance' # TODO: add support for bank accounts in foreign currency # if not o.currency_id else 'amount_currency' query = """ - SELECT sum(%s) FROM account_move_line - WHERE account_id=%%s AND date <= %%s""" % (amount_field, ) + SELECT sum(balance) FROM account_move_line + WHERE account_id=%s AND date <= %s""" self.env.cr.execute(query, (bank_account.id, date)) query_results = self.env.cr.dictfetchall() if query_results: - account_bal = query_results[0].get('sum') or 0.0 + account_bal = query_results[0].get("sum") or 0.0 else: account_bal = 0.0 return account_bal def _prepare_move_lines(self, journal, date): bank_account = journal.default_debit_account_id - mlines = self.env['account.move.line'].search([ - ('account_id', '=', bank_account.id), - ('journal_id', '=', journal.id), # to avoid initial line - ('date', '<=', date), - '|', ('statement_line_date', '=', False), - ('statement_line_date', '>', date)]) + mlines = self.env["account.move.line"].search( + [ + ("account_id", "=", bank_account.id), + ("journal_id", "=", journal.id), # to avoid initial line + ("date", "<=", date), + "|", + ("statement_line_date", "=", False), + ("statement_line_date", ">", date), + ] + ) res = [] for mline in mlines: move = mline.move_id cpart = [] for line in move.line_ids: if ( - line.account_id != bank_account and - line.account_id.code not in cpart): + line.account_id != bank_account + and line.account_id.code not in cpart + ): cpart.append(line.account_id.code) - counterpart = ' ,'.join(cpart) - res.append({ - 'date': mline.date, - 'label': mline.name, - 'ref': mline.ref or '', - 'partner': mline.partner_id.display_name or '', - 'amount': mline.balance, - 'statement_line_date': mline.statement_line_date or '', - 'move_number': move.name, - 'counterpart': counterpart, - }) + counterpart = " ,".join(cpart) + res.append( + { + "date": mline.date, + "label": mline.name, + "ref": mline.ref or "", + "partner": mline.partner_id.display_name or "", + "amount": mline.balance, + "statement_line_date": mline.statement_line_date or "", + "move_number": move.name, + "counterpart": counterpart, + } + ) return res def _prepare_draft_statement_lines(self, journal, date): - blines = self.env['account.bank.statement.line'].search([ - ('journal_entry_ids', '=', False), - ('journal_id', '=', journal.id), - ('date', '<=', date)]) + blines = self.env["account.bank.statement.line"].search( + [ + ("journal_entry_ids", "=", False), + ("journal_id", "=", journal.id), + ("date", "<=", date), + ] + ) res = [] for bline in blines: - res.append({ - 'date': bline.date, - 'label': bline.name, - 'ref': bline.ref or '', - 'partner': bline.partner_id.display_name or '', - 'amount': bline.amount, - 'statement_ref': bline.statement_id.display_name, - }) + res.append( + { + "date": bline.date, + "label": bline.name, + "ref": bline.ref or "", + "partner": bline.partner_id.display_name or "", + "amount": bline.amount, + "statement_ref": bline.statement_id.display_name, + } + ) return res def generate_xlsx_report(self, workbook, data, wizard): @@ -83,57 +94,77 @@ class BankReconciliationXlsx(models.AbstractModel): lang_code = self.env.user.lang lang = False if lang_code: - lang = self.env['res.lang'].search([('code', '=', lang_code)]) + lang = self.env["res.lang"].search([("code", "=", lang_code)]) if not lang: - lang = self.env['res.lang'].search([], limit=1) - xls_date_format = lang.date_format.replace('%Y', 'yyyy').\ - replace('%m', 'mm').replace('%d', 'dd').replace('%y', 'yy') + lang = self.env["res.lang"].search([], limit=1) + xls_date_format = ( + lang.date_format.replace("%Y", "yyyy") + .replace("%m", "mm") + .replace("%d", "dd") + .replace("%y", "yy") + ) - doc_title = workbook.add_format({'bold': True, 'font_size': 16}) - col_title = workbook.add_format({ - 'bold': True, 'bg_color': '#e2e2fa', - 'text_wrap': True, 'font_size': 10, - }) - title_right = workbook.add_format({ - 'bold': True, 'bg_color': '#e6e6fa', - 'font_size': 10, 'align': 'right', - }) - title_date = workbook.add_format({ - 'bg_color': '#f6f6ff', 'bold': True, - 'num_format': xls_date_format, - 'font_size': 10, - 'align': 'left'}) - label_bold = workbook.add_format({ - 'bold': True, 'text_wrap': False, 'font_size': 10}) - none = workbook.add_format({ - 'bold': True, 'font_size': 10, 'align': 'right'}) - regular = workbook.add_format({'font_size': 10}) - if '%' in xls_date_format: + doc_title = workbook.add_format({"bold": True, "font_size": 16}) + col_title = workbook.add_format( + { + "bold": True, + "bg_color": "#e2e2fa", + "text_wrap": True, + "font_size": 10, + } + ) + title_right = workbook.add_format( + { + "bold": True, + "bg_color": "#e6e6fa", + "font_size": 10, + "align": "right", + } + ) + title_date = workbook.add_format( + { + "bg_color": "#f6f6ff", + "bold": True, + "num_format": xls_date_format, + "font_size": 10, + "align": "left", + } + ) + label_bold = workbook.add_format( + {"bold": True, "text_wrap": False, "font_size": 10} + ) + none = workbook.add_format( + {"bold": True, "font_size": 10, "align": "right"} + ) + regular = workbook.add_format({"font_size": 10}) + if "%" in xls_date_format: # fallback - xls_date_format = 'yyyy-mm-dd' - regular_date = workbook.add_format({ - 'num_format': xls_date_format, - 'font_size': 10, - 'align': 'left'}) - cur_format = u'#,##0.00 %s' % ( - o.company_id.currency_id.symbol or - o.company_id.currency_id.name) + xls_date_format = "yyyy-mm-dd" + regular_date = workbook.add_format( + {"num_format": xls_date_format, "font_size": 10, "align": "left"} + ) + cur_format = u"#,##0.00 %s" % ( + o.company_id.currency_id.symbol or o.company_id.currency_id.name + ) # It seems that Excel replaces automatically the decimal # and thousand separator by those of the language under which # Excel runs regular_currency = workbook.add_format( - {'num_format': cur_format, 'font_size': 10}) - regular_currency_bg = workbook.add_format({ - 'num_format': cur_format, 'font_size': 10, - 'bg_color': '#f6f6ff'}) + {"num_format": cur_format, "font_size": 10} + ) + regular_currency_bg = workbook.add_format( + {"num_format": cur_format, "font_size": 10, "bg_color": "#f6f6ff"} + ) # End styles sheet = workbook.add_worksheet(o.code or o.name) sheet.write( - 0, 0, - _('%s - %s - Bank Reconciliation') % ( - o.company_id.name, o.display_name), - doc_title) + 0, + 0, + _("%s - %s - Bank Reconciliation") + % (o.company_id.name, o.display_name), + doc_title, + ) sheet.set_row(0, 26) sheet.set_row(1, 25) sheet.set_column(0, 0, 10) @@ -151,32 +182,38 @@ class BankReconciliationXlsx(models.AbstractModel): row += 2 bank_account = o.default_debit_account_id for col in range(3): - sheet.write(row, col, '', title_right) - sheet.write( - row, 3, - _('Balance %s:') % bank_account.code, title_right) + sheet.write(row, col, "", title_right) + sheet.write(row, 3, _("Balance %s:") % bank_account.code, title_right) account_bal = self._compute_account_balance(o, date) sheet.write(row, 4, account_bal, regular_currency_bg) bank_bal = account_bal - formula = '=E%d' % (row + 1) + formula = "=E%d" % (row + 1) # 2) Show account move line that are not linked to bank statement # line or linked to a statement line after the date row += 2 sheet.write( - row, 0, _( - 'Journal items of account %s not linked to a bank ' - 'statement line:') % bank_account.code, - label_bold) + row, + 0, + _("Journal items of account %s not linked to a bank " "statement line:") + % bank_account.code, + label_bold, + ) mlines = self._prepare_move_lines(o, date) if not mlines: - sheet.write(row, 4, _('NONE'), none) + sheet.write(row, 4, _("NONE"), none) else: row += 1 col_labels = [ - _('Date'), _('Label'), _('Ref.'), _('Partner'), - _('Amount'), _('Statement Line Date'), _('Move Number'), - _('Counter-part')] + _("Date"), + _("Label"), + _("Ref."), + _("Partner"), + _("Amount"), + _("Statement Line Date"), + _("Move Number"), + _("Counter-part"), + ] col = 0 for col_label in col_labels: sheet.write(row, col, col_label, col_title) @@ -185,33 +222,36 @@ class BankReconciliationXlsx(models.AbstractModel): for mline in mlines: row += 1 m_end_row = row - bank_bal -= mline['amount'] - sheet.write(row, 0, mline['date'], regular_date) - sheet.write(row, 1, mline['label'], regular) - sheet.write(row, 2, mline['ref'], regular) - sheet.write(row, 3, mline['partner'], regular) - sheet.write(row, 4, mline['amount'], regular_currency) - sheet.write( - row, 5, mline['statement_line_date'], regular_date) - sheet.write(row, 6, mline['move_number'], regular) - sheet.write(row, 7, mline['counterpart'], regular) + bank_bal -= mline["amount"] + sheet.write(row, 0, mline["date"], regular_date) + sheet.write(row, 1, mline["label"], regular) + sheet.write(row, 2, mline["ref"], regular) + sheet.write(row, 3, mline["partner"], regular) + sheet.write(row, 4, mline["amount"], regular_currency) + sheet.write(row, 5, mline["statement_line_date"], regular_date) + sheet.write(row, 6, mline["move_number"], regular) + sheet.write(row, 7, mline["counterpart"], regular) - formula += '-SUM(E%d:E%d)' % (m_start_row + 1, m_end_row + 1) + formula += "-SUM(E%d:E%d)" % (m_start_row + 1, m_end_row + 1) # 3) Add draft bank statement lines row += 2 # skip 1 line - sheet.write( - row, 0, _( - 'Draft bank statement lines:'), - label_bold) + sheet.write(row, 0, _("Draft bank statement lines:"), label_bold) blines = self._prepare_draft_statement_lines(o, date) if not blines: - sheet.write(row, 4, _('NONE'), none) + sheet.write(row, 4, _("NONE"), none) else: row += 1 col_labels = [ - _('Date'), _('Label'), _('Ref.'), - _('Partner'), _('Amount'), _('Statement Ref.'), '', ''] + _("Date"), + _("Label"), + _("Ref."), + _("Partner"), + _("Amount"), + _("Statement Ref."), + "", + "", + ] col = 0 for col_label in col_labels: sheet.write(row, col, col_label, col_title) @@ -220,31 +260,35 @@ class BankReconciliationXlsx(models.AbstractModel): for bline in blines: row += 1 b_end_row = row - bank_bal += bline['amount'] - sheet.write(row, 0, bline['date'], regular_date) - sheet.write(row, 1, bline['label'], regular) - sheet.write(row, 2, bline['ref'], regular) - sheet.write(row, 3, bline['partner'], regular) - sheet.write(row, 4, bline['amount'], regular_currency) - sheet.write( - row, 5, bline['statement_ref'], regular_currency) - formula += '+SUM(E%d:E%d)' % (b_start_row + 1, b_end_row + 1) + bank_bal += bline["amount"] + sheet.write(row, 0, bline["date"], regular_date) + sheet.write(row, 1, bline["label"], regular) + sheet.write(row, 2, bline["ref"], regular) + sheet.write(row, 3, bline["partner"], regular) + sheet.write(row, 4, bline["amount"], regular_currency) + sheet.write(row, 5, bline["statement_ref"], regular_currency) + formula += "+SUM(E%d:E%d)" % (b_start_row + 1, b_end_row + 1) # 4) Theoric bank account balance at the bank row += 2 for col in range(3): - sheet.write(row, col, '', title_right) + sheet.write(row, col, "", title_right) sheet.write( - row, 3, _('Computed Bank Account Balance at the Bank:'), - title_right) - sheet.write_formula( - row, 4, formula, regular_currency_bg, bank_bal) + row, 3, _("Computed Bank Account Balance at the Bank:"), title_right + ) + sheet.write_formula(row, 4, formula, regular_currency_bg, bank_bal) if no_bank_journal: - sheet = workbook.add_worksheet(_('No Bank Journal')) + sheet = workbook.add_worksheet(_("No Bank Journal")) sheet.set_row(0, 30) warn_msg = workbook.add_format( - {'bold': True, 'font_size': 16, 'font_color': '#003b6f'}) + {"bold": True, "font_size": 16, "font_color": "#003b6f"} + ) sheet.write( - 0, 0, _( + 0, + 0, + _( "No bank journal selected. " - "This report is only for bank journals."), warn_msg) + "This report is only for bank journals." + ), + warn_msg, + ) diff --git a/account_bank_reconciliation_summary_xlsx/report/report.xml b/account_bank_reconciliation_summary_xlsx/report/report.xml index c7a9ce25..25c2e8de 100644 --- a/account_bank_reconciliation_summary_xlsx/report/report.xml +++ b/account_bank_reconciliation_summary_xlsx/report/report.xml @@ -1,21 +1,18 @@ - + - - - + - diff --git a/account_bank_reconciliation_summary_xlsx/views/account_bank_statement.xml b/account_bank_reconciliation_summary_xlsx/views/account_bank_statement.xml index 9b57a3ae..377e80ee 100644 --- a/account_bank_reconciliation_summary_xlsx/views/account_bank_statement.xml +++ b/account_bank_reconciliation_summary_xlsx/views/account_bank_statement.xml @@ -1,24 +1,23 @@ - + - - - - - bank_rec_summary.account.bank.statement.form - account.bank.statement - - - - - - - + + bank_rec_summary.account.bank.statement.form + account.bank.statement + + + + + diff --git a/account_bank_reconciliation_summary_xlsx/views/account_journal.xml b/account_bank_reconciliation_summary_xlsx/views/account_journal.xml index 5340adb2..6d4b9677 100644 --- a/account_bank_reconciliation_summary_xlsx/views/account_journal.xml +++ b/account_bank_reconciliation_summary_xlsx/views/account_journal.xml @@ -1,32 +1,32 @@ - + - - - - - bank_reconciliation_summarry.account_journal_dashboard - account.journal - - - -
-
- Report + + + bank_reconciliation_summarry.account_journal_dashboard + account.journal + + + +
+
+ Report +
+
- -
- - - - - + + + diff --git a/account_bank_reconciliation_summary_xlsx/views/account_move_line.xml b/account_bank_reconciliation_summary_xlsx/views/account_move_line.xml index 0afd4b68..da8eec8a 100644 --- a/account_bank_reconciliation_summary_xlsx/views/account_move_line.xml +++ b/account_bank_reconciliation_summary_xlsx/views/account_move_line.xml @@ -1,23 +1,18 @@ - + - - - - - bank_rec_summary.account_move_line_form - account.move.line - - - - + + bank_rec_summary.account_move_line_form + account.move.line + + + + + - - - - + diff --git a/account_bank_reconciliation_summary_xlsx/wizard/bank_reconciliation_report_wizard.py b/account_bank_reconciliation_summary_xlsx/wizard/bank_reconciliation_report_wizard.py index 591d0c32..b469f8a5 100644 --- a/account_bank_reconciliation_summary_xlsx/wizard/bank_reconciliation_report_wizard.py +++ b/account_bank_reconciliation_summary_xlsx/wizard/bank_reconciliation_report_wizard.py @@ -11,24 +11,27 @@ class BankReconciliationReportWizard(models.TransientModel): @api.model def _default_journal_ids(self): - journals = self.env['account.journal'].search([ - ('type', '=', 'bank'), - ('bank_account_id', '!=', False), - ('company_id', '=', self.env.user.company_id.id), - ]) + journals = self.env["account.journal"].search( + [ + ("type", "=", "bank"), + ("bank_account_id", "!=", False), + ("company_id", "=", self.env.user.company_id.id), + ] + ) return journals - date = fields.Date( - required=True, - default=fields.Date.context_today) + date = fields.Date(required=True, default=fields.Date.context_today) journal_ids = fields.Many2many( - 'account.journal', string='Bank Journals', - domain=[('type', '=', 'bank')], required=True, - default=lambda self: self._default_journal_ids()) + "account.journal", + string="Bank Journals", + domain=[("type", "=", "bank")], + required=True, + default=lambda self: self._default_journal_ids(), + ) def open_xlsx(self): report = self.env.ref( - 'account_bank_reconciliation_summary_xlsx.' - 'bank_reconciliation_xlsx') + "account_bank_reconciliation_summary_xlsx." "bank_reconciliation_xlsx" + ) action = report.report_action(self) return action diff --git a/account_bank_reconciliation_summary_xlsx/wizard/bank_reconciliation_report_wizard_view.xml b/account_bank_reconciliation_summary_xlsx/wizard/bank_reconciliation_report_wizard_view.xml index 692c2c46..caba845e 100644 --- a/account_bank_reconciliation_summary_xlsx/wizard/bank_reconciliation_report_wizard_view.xml +++ b/account_bank_reconciliation_summary_xlsx/wizard/bank_reconciliation_report_wizard_view.xml @@ -1,42 +1,42 @@ - + - - - - - bank.reconciliation.report.wizard.form - bank.reconciliation.report.wizard - -
- - - - -
-
-
-
-
- - - Bank Reconciliation - bank.reconciliation.report.wizard - form - new - - - + bank.reconciliation.report.wizard.form + bank.reconciliation.report.wizard + +
+ + + + +
+
+
+
+ + + Bank Reconciliation + bank.reconciliation.report.wizard + form + new + + - - + sequence="100" + />
diff --git a/setup/account_bank_reconciliation_summary_xlsx/odoo/addons/account_bank_reconciliation_summary_xlsx b/setup/account_bank_reconciliation_summary_xlsx/odoo/addons/account_bank_reconciliation_summary_xlsx new file mode 120000 index 00000000..aa51326d --- /dev/null +++ b/setup/account_bank_reconciliation_summary_xlsx/odoo/addons/account_bank_reconciliation_summary_xlsx @@ -0,0 +1 @@ +../../../../account_bank_reconciliation_summary_xlsx \ No newline at end of file diff --git a/setup/account_bank_reconciliation_summary_xlsx/setup.py b/setup/account_bank_reconciliation_summary_xlsx/setup.py new file mode 100644 index 00000000..28c57bb6 --- /dev/null +++ b/setup/account_bank_reconciliation_summary_xlsx/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)