From eb2b7999ff07c50c672fb921640e1b4acaabe7e2 Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Sun, 29 Oct 2017 02:16:48 +0200 Subject: [PATCH] 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 @@ +