Browse Source

Fine tune layout bank reconciliation report

Report is technically linked to wizard, not to account.journal
pull/322/head
Alexis de Lattre 7 years ago
parent
commit
eb2b7999ff
  1. 2
      account_bank_reconciliation_summary_xlsx/__manifest__.py
  2. 1
      account_bank_reconciliation_summary_xlsx/models/__init__.py
  3. 22
      account_bank_reconciliation_summary_xlsx/models/account_bank_statement.py
  4. 61
      account_bank_reconciliation_summary_xlsx/report/bank_reconciliation_xlsx.py
  5. 2
      account_bank_reconciliation_summary_xlsx/report/report.xml
  6. 4
      account_bank_reconciliation_summary_xlsx/views/account_bank_statement.xml
  7. 8
      account_bank_reconciliation_summary_xlsx/wizard/bank_reconciliation_report_wizard.py
  8. 3
      account_bank_reconciliation_summary_xlsx/wizard/bank_reconciliation_report_wizard_view.xml

2
account_bank_reconciliation_summary_xlsx/__manifest__.py

@ -12,9 +12,9 @@
'depends': ['account', 'report_xlsx'], 'depends': ['account', 'report_xlsx'],
'data': [ 'data': [
'report/report.xml', 'report/report.xml',
'wizard/bank_reconciliation_report_wizard_view.xml',
'views/account_bank_statement.xml', 'views/account_bank_statement.xml',
'views/account_move_line.xml', 'views/account_move_line.xml',
'wizard/bank_reconciliation_report_wizard_view.xml',
], ],
'installable': True, 'installable': True,
} }

1
account_bank_reconciliation_summary_xlsx/models/__init__.py

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from . import account_bank_statement
from . import account_move_line from . import account_move_line

22
account_bank_reconciliation_summary_xlsx/models/account_bank_statement.py

@ -1,22 +0,0 @@
# -*- coding: utf-8 -*-
# © 2017 Akretion France (Alexis de Lattre <alexis.delattre@akretion.com>)
# 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

61
account_bank_reconciliation_summary_xlsx/report/bank_reconciliation_xlsx.py

@ -10,12 +10,11 @@ from datetime import datetime
class BankReconciliationXlsx(ReportXlsx): 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) date_dt = fields.Date.from_string(date)
no_bank_journal = True no_bank_journal = True
for o in journals.filtered(lambda o: o.type == 'bank'):
for o in wizard.journal_ids:
no_bank_journal = False no_bank_journal = False
# Start styles # Start styles
lang_code = self.env.user.lang lang_code = self.env.user.lang
@ -77,14 +76,17 @@ class BankReconciliationXlsx(ReportXlsx):
sheet.set_column(2, 2, 15) sheet.set_column(2, 2, 15)
sheet.set_column(3, 3, 25) sheet.set_column(3, 3, 25)
sheet.set_column(4, 4, 12) 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 row = 2
sheet.write(row, 0, _("Date:"), title_right) sheet.write(row, 0, _("Date:"), title_right)
sheet.write(row, 1, date_dt, title_date) sheet.write(row, 1, date_dt, title_date)
# 1) Show accounting balance of bank account # 1) Show accounting balance of bank account
row += 1
row += 2
bank_account = o.default_debit_account_id bank_account = o.default_debit_account_id
for col in range(3):
sheet.write(row, col, '', title_right)
sheet.write( sheet.write(
row, 3, row, 3,
_('Balance %s:') % bank_account.code, title_right) _('Balance %s:') % bank_account.code, title_right)
@ -122,30 +124,33 @@ class BankReconciliationXlsx(ReportXlsx):
sheet.write(row, 4, _('NONE'), none) sheet.write(row, 4, _('NONE'), none)
else: else:
row += 1 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 m_start_row = m_end_row = row + 1
for mline in mlines: for mline in mlines:
row += 1 row += 1
m_end_row = row m_end_row = row
move = mline.move_id move = mline.move_id
bank_bal -= mline.balance 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, 0, date_dt, regular_date)
sheet.write(row, 1, mline.name, regular) sheet.write(row, 1, mline.name, regular)
sheet.write(row, 2, mline.ref or '', regular) sheet.write(row, 2, mline.ref or '', regular)
sheet.write( sheet.write(
row, 3, mline.partner_id.display_name or '', regular) row, 3, mline.partner_id.display_name or '', regular)
sheet.write(row, 4, mline.balance, regular_currency) 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) sheet.write(row, 6, move.name, regular)
# counter-part accounts # counter-part accounts
cpart = [] cpart = []
@ -172,12 +177,13 @@ class BankReconciliationXlsx(ReportXlsx):
sheet.write(row, 4, _('NONE'), none) sheet.write(row, 4, _('NONE'), none)
else: else:
row += 1 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 b_start_row = b_end_row = row + 1
for bline in blines: for bline in blines:
row += 1 row += 1
@ -198,6 +204,8 @@ class BankReconciliationXlsx(ReportXlsx):
# 4) Theoric bank account balance at the bank # 4) Theoric bank account balance at the bank
row += 2 row += 2
for col in range(3):
sheet.write(row, col, '', title_right)
sheet.write( sheet.write(
row, 3, _('Computed Bank Account Balance at the Bank:'), row, 3, _('Computed Bank Account Balance at the Bank:'),
title_right) title_right)
@ -214,4 +222,5 @@ class BankReconciliationXlsx(ReportXlsx):
"This report is only for bank journals."), warn_msg) "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')

2
account_bank_reconciliation_summary_xlsx/report/report.xml

@ -8,7 +8,7 @@
<report <report
id="bank_reconciliation_xlsx" id="bank_reconciliation_xlsx"
model="account.journal"
model="bank.reconciliation.report.wizard"
string="Bank Reconciliation XLSX" string="Bank Reconciliation XLSX"
report_type="xlsx" report_type="xlsx"
name="bank.reconciliation.xlsx" name="bank.reconciliation.xlsx"

4
account_bank_reconciliation_summary_xlsx/views/account_bank_statement.xml

@ -13,8 +13,8 @@
<field name="inherit_id" ref="account.view_bank_statement_form"/> <field name="inherit_id" ref="account.view_bank_statement_form"/>
<field name="arch" type="xml"> <field name="arch" type="xml">
<button name="check_confirm_bank" position="after"> <button name="check_confirm_bank" position="after">
<button name="print_reconciliation_xlsx" type="object"
string="Bank Reconciliation Report"/>
<button name="%(bank_reconciliation_report_wizard_action)d" type="action"
string="Bank Reconciliation Report" context="{'default_journal_ids': [journal_id]}"/>
</button> </button>
</field> </field>
</record> </record>

8
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)]) ('company_id', '=', self.env.user.company_id.id)])
return journals return journals
company_id = fields.Many2one(
'res.company', string='Company',
default=lambda self: self.env.user.company_id)
date = fields.Date( date = fields.Date(
required=True, required=True,
default=fields.Date.context_today) default=fields.Date.context_today)
@ -32,8 +29,9 @@ class BankReconciliationReportWizard(models.TransientModel):
'type': 'ir.actions.report.xml', 'type': 'ir.actions.report.xml',
'report_name': 'bank.reconciliation.xlsx', 'report_name': 'bank.reconciliation.xlsx',
'datas': { 'datas': {
'model': 'account.journal',
'ids': self.journal_ids.ids,
'model': self._name,
'ids': self.ids,
'journal_ids': self.journal_ids.ids,
'date': self.date, 'date': self.date,
}, },
'context': self._context, 'context': self._context,

3
account_bank_reconciliation_summary_xlsx/wizard/bank_reconciliation_report_wizard_view.xml

@ -6,13 +6,13 @@
<odoo> <odoo>
<record id="bank_reconciliation_report_wizard_form" model="ir.ui.view"> <record id="bank_reconciliation_report_wizard_form" model="ir.ui.view">
<field name="name">bank.reconciliation.report.wizard.form</field> <field name="name">bank.reconciliation.report.wizard.form</field>
<field name="model">bank.reconciliation.report.wizard</field> <field name="model">bank.reconciliation.report.wizard</field>
<field name="arch" type="xml"> <field name="arch" type="xml">
<form string="Bank Reconciliation Report"> <form string="Bank Reconciliation Report">
<group name="main"> <group name="main">
<field name="company_id" groups="base.group_multi_company"/>
<field name="date"/> <field name="date"/>
<field name="journal_ids" widget="many2many_tags"/> <field name="journal_ids" widget="many2many_tags"/>
</group> </group>
@ -33,4 +33,5 @@
<menuitem id="bank_reconciliation_report_wizard_menu" action="bank_reconciliation_report_wizard_action" parent="account.menu_finance_reports" groups="account.group_account_manager,account.group_account_user"/> <menuitem id="bank_reconciliation_report_wizard_menu" action="bank_reconciliation_report_wizard_action" parent="account.menu_finance_reports" groups="account.group_account_manager,account.group_account_user"/>
</odoo> </odoo>
Loading…
Cancel
Save