Fine tune layout bank reconciliation report
Report is technically linked to wizard, not to account.journalpull/699/head
parent
03c1a8924a
commit
ef250fbb63
|
@ -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,
|
||||
}
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
from . import account_bank_statement
|
||||
from . import account_move_line
|
||||
|
|
|
@ -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
|
|
@ -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')
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
<report
|
||||
id="bank_reconciliation_xlsx"
|
||||
model="account.journal"
|
||||
model="bank.reconciliation.report.wizard"
|
||||
string="Bank Reconciliation XLSX"
|
||||
report_type="xlsx"
|
||||
name="bank.reconciliation.xlsx"
|
||||
|
|
|
@ -13,8 +13,8 @@
|
|||
<field name="inherit_id" ref="account.view_bank_statement_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<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>
|
||||
</field>
|
||||
</record>
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -6,13 +6,13 @@
|
|||
|
||||
<odoo>
|
||||
|
||||
|
||||
<record id="bank_reconciliation_report_wizard_form" model="ir.ui.view">
|
||||
<field name="name">bank.reconciliation.report.wizard.form</field>
|
||||
<field name="model">bank.reconciliation.report.wizard</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Bank Reconciliation Report">
|
||||
<group name="main">
|
||||
<field name="company_id" groups="base.group_multi_company"/>
|
||||
<field name="date"/>
|
||||
<field name="journal_ids" widget="many2many_tags"/>
|
||||
</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"/>
|
||||
|
||||
|
||||
</odoo>
|
||||
|
|
Loading…
Reference in New Issue