Browse Source

[ADD][8.0] module "bank_statement_reconciliation_summary"

pull/202/head
jbeficent 9 years ago
parent
commit
2994f9e634
  1. 141
      bank_statement_reconciliation_summary/README.rst
  2. 8
      bank_statement_reconciliation_summary/__init__.py
  3. 21
      bank_statement_reconciliation_summary/__openerp__.py
  4. 6
      bank_statement_reconciliation_summary/models/__init__.py
  5. 12
      bank_statement_reconciliation_summary/models/account_account.py
  6. 23
      bank_statement_reconciliation_summary/models/account_bank_statement.py
  7. 5
      bank_statement_reconciliation_summary/report/__init__.py
  8. 33
      bank_statement_reconciliation_summary/report/report.xml
  9. 63
      bank_statement_reconciliation_summary/report/summary_report.py
  10. 202
      bank_statement_reconciliation_summary/report/summary_report.xml
  11. 17
      bank_statement_reconciliation_summary/view/account_account_view.xml
  12. 34
      bank_statement_reconciliation_summary/view/account_bank_statement.xml
  13. 5
      bank_statement_reconciliation_summary/wizard/__init__.py
  14. 93
      bank_statement_reconciliation_summary/wizard/account_bank_unreconcile.py
  15. 30
      bank_statement_reconciliation_summary/wizard/account_bank_unreconcile_view.xml

141
bank_statement_reconciliation_summary/README.rst

@ -0,0 +1,141 @@
.. 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 Statement Reconciliation Summary
=====================================
The Bank Reconciliation Summary shows how your actual bank statement balance
and the balance of the bank account in Odoo match, after taking into account
any unreconciled items.
This report is useful if your bank account's statement balance and balance
in Odoo do not match, and you need to check for duplicate or manually created
transactions that might cause the discrepancy.
This report was created, inspired by Xero’s bank reconciliation summary,
https://help.xero.com/Report_BankRec, and from a basic explanation of the
bank statement reconciliation summary:
http://www.accountingcoach.com/bank-reconciliation/explanation.
Usage
=====
Define Accounts
---------------
There are three accounts associated to a bank account:
* Bank account view
* Bank Account. Matches the statement
* Bank Clearing Account. Is used for uncleared payments and receipts. The
Bank Clearing Account is a reconcilable account.
In the definition of the bank account that is used to match with the bank
statement, define what will be the GL account used to record the uncleared
payments and receipts.
Define Account Journals
-----------------------
Create the following journals:
* Journal for Bank Statement reconciliation
* Journal to enter Payments and Receipts that have not yet cleared to the bank
Enter payments and receipts
---------------------------
Every time an invoice is paid, use the Journal to enter Payments and Receipts.
It will generate:
Dr. Accounts Payable
Cr. Bank Clearing Account
Create a bank statement
-----------------------
Create a bank statement and select the Journal defined for bank statement
reconciliation.
If you do not use a tool to integrate automatically the bank statement feed
into Odoo, you can press press the button “Import Payments and Receipts”
in order to add to the statements the payments and receipts that have been
generated, but that have not yet cleared the bank.
Use the “Reconcile” button to reconcile the entries in the bank statement
with the payments and receipts that have already cleared the bank.
If you chose to import the statement lines from uncleared payments and
receipts, this will be the moment where you will visually compare with the
online/paper bank statement, and reconcile the items that truly cleared the
bank.
The Odoo Bank Reconciliation Wizard will be used by the user to specifically
create the Bank Account entries by linking the Bank Statement lines with the
Bank Clearing Account items.
Dr. Bank Clearing Account
Cr. Bank Account
Once you have completed this process, some statement lines may be left
unreconciled (because they were truly not present in the online/physical
statement). In that case you can press the button “Remove Unreconciled”.
Print bank statement reconciliation summary
-------------------------------------------
It will report on the current balance of the Bank Account, and will show the
unreconciled entries of the Bank Clearing Account, classifying the them
between Outstanding Payments (that is, credits in the Bank Clearing Account)
and Outstanding Receipts (that is, debits in the Bank Clearing Account).
The application will also show the bank statement lines that have not yet
been reconciled yet, if any exists.
Once the user has fully processed the reconciliation with the bank clearing
account, all the entries in this bank clearing account should be reconciled,
and the bank account (used to match with the Statement) will truly
reflect the same information as the bank statement balance.
From a bank account perspective, the total amount held in the bank is the
sum of the balances of the bank clearing account (which should normally
show undeposited checks, for example) and the bank account used to match
with the statement.
.. 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/8.0
Known issues / Roadmap
======================
* For Odoo v9 there will be no need to use the clearing account.
Bug Tracker
===========
Bugs are tracked on `GitHub Issues <https://github.com/OCA/account-financial-reporting/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
`here <https://github.com/OCA/account-financial-reporting/issues/new?body=module:%20account_tax_report_no_zeroes%0Aversion:%208.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
Credits
=======
Contributors
------------
* Jordi Ballester Alomar <contact@eficent.com>
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 http://odoo-community.org.

8
bank_statement_reconciliation_summary/__init__.py

@ -0,0 +1,8 @@
# -*- coding: utf-8 -*-
# © 2016 Eficent Business and IT Consulting Services S.L.
# © 2016 Serpent Consulting Services Pvt. Ltd.
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
import models
import report
import wizard

21
bank_statement_reconciliation_summary/__openerp__.py

@ -0,0 +1,21 @@
# -*- coding: utf-8 -*-
# © 2016 Eficent Business and IT Consulting Services S.L.
# © 2016 Serpent Consulting Services Pvt. Ltd.
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
{
'name': 'Bank Statement Reconciliation Summary',
'category': 'Account',
'summary': 'Bank Statement Reconciliation Summary',
'version': '8.0.1.0.0',
'author': 'Eficent Business and IT Consulting Services S.L., '
'Serpent Consulting Services Pvt. Ltd.',
'depends': ['account'],
'data': [
'report/summary_report.xml',
'report/report.xml',
'view/account_account_view.xml',
'wizard/account_bank_unreconcile_view.xml',
'view/account_bank_statement.xml',
],
'installable': True,
}

6
bank_statement_reconciliation_summary/models/__init__.py

@ -0,0 +1,6 @@
# -*- coding: utf-8 -*-
# © 2016 Eficent Business and IT Consulting Services S.L.
# © 2016 Serpent Consulting Services Pvt. Ltd.
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from . import account_account
from . import account_bank_statement

12
bank_statement_reconciliation_summary/models/account_account.py

@ -0,0 +1,12 @@
# -*- coding: utf-8 -*-
# © 2016 Eficent Business and IT Consulting Services S.L.
# © 2016 Serpent Consulting Services Pvt. Ltd.
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from openerp import models, fields
class AccountAccount(models.Model):
_inherit = 'account.account'
clearing_account_id = fields.Many2one('account.account',
'Clearing Account')

23
bank_statement_reconciliation_summary/models/account_bank_statement.py

@ -0,0 +1,23 @@
# -*- coding: utf-8 -*-
# © 2016 Eficent Business and IT Consulting Services S.L.
# © 2016 Serpent Consulting Services Pvt. Ltd.
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from openerp import api, fields, models
class AccountBankStatement(models.Model):
_inherit = 'account.bank.statement'
@api.multi
def delete_unreconciled(self):
self.ensure_one()
for line in self.line_ids:
if not line.journal_entry_id:
line.unlink()
class AccountBankStatementLine(models.Model):
_inherit = 'account.bank.statement.line'
clearing_move_line_id = fields.Many2one('account.move.line',
'Clearing Move Line')

5
bank_statement_reconciliation_summary/report/__init__.py

@ -0,0 +1,5 @@
# -*- coding: utf-8 -*-
# © 2016 Eficent Business and IT Consulting Services S.L.
# © 2016 Serpent Consulting Services Pvt. Ltd.
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
import summary_report

33
bank_statement_reconciliation_summary/report/report.xml

@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<openerp>
<data>
<record id="summary_report_paperformat" model="report.paperformat">
<field name="name">Bank Statement Reconcillation Summary Paperformat</field>
<field name="default" eval="True" />
<field name="format">A4</field>
<field name="page_height">0</field>
<field name="page_width">0</field>
<field name="orientation">Portrait</field>
<field name="margin_top">0</field>
<field name="margin_bottom">0</field>
<field name="margin_left">5</field>
<field name="margin_right">5</field>
<field name="header_line" eval="False" />
<field name="header_spacing">0</field>
<field name="dpi">90</field>
</record>
<report id="report_bank_stmt_reconcile_summary"
string="Bank Statement Reconcillation Summary"
model="account.bank.statement"
report_type="qweb-pdf"
file="bank_statement_reconciliation_summary.summary_report"
name="bank_statement_reconciliation_summary.summary_report"/>
<record id="report_bank_stmt_reconcile_summary" model="ir.actions.report.xml">
<field name="paperformat_id" ref="summary_report_paperformat"/>
</record>
</data>
</openerp>

63
bank_statement_reconciliation_summary/report/summary_report.py

@ -0,0 +1,63 @@
# -*- coding: utf-8 -*-
# © 2016 Eficent Business and IT Consulting Services S.L.
# © 2016 Serpent Consulting Services Pvt. Ltd.
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
import time
from openerp import api, models
class SummaryReport(models.AbstractModel):
_name = 'report.bank_statement_reconciliation_summary.summary_report'
@api.model
def _plus_outstanding_payments(self, journal_record):
account_id = journal_record.default_credit_account_id and\
journal_record.default_credit_account_id.clearing_account_id and\
journal_record.default_credit_account_id.clearing_account_id.id
account_move_line_records = self.env['account.move.line'].search([
('account_id', '=', account_id),
('reconcile_id', '=', False),
('account_id.reconcile', '=', True),
('credit', '>', 0.00)
], order='date')
return account_move_line_records
@api.model
def _less_outstanding_receipts(self, journal_record):
account_id = journal_record.default_credit_account_id and\
journal_record.default_credit_account_id.clearing_account_id and\
journal_record.default_credit_account_id.clearing_account_id.id
account_move_line_records = self.env['account.move.line'].search([
('account_id', '=', account_id),
('reconcile_id', '=', False),
('account_id.reconcile', '=', True),
('debit', '>', 0.00)
], order='date')
return account_move_line_records
@api.model
def _plus_unreconciled_statement_lines(self, statement):
statement_lines = self.env['account.bank.statement.line'].browse()
for line in statement.line_ids:
if not line.journal_entry_id:
statement_lines += line
return statement_lines or False
@api.multi
def render_html(self, data=None):
Report = self.env['report']
report_name = 'bank_statement_reconciliation_summary.summary_report'
report = Report._get_report_from_name(report_name)
records = self.env['account.bank.statement'].browse(self.ids)
docargs = {
'doc_ids': self.ids,
'doc_model': report.model,
'data': data,
'docs': records,
'time': time,
'plus_outstanding_payments': self._plus_outstanding_payments,
'less_outstanding_receipts': self._less_outstanding_receipts,
'plus_unreconciled_statement_lines':
self._plus_unreconciled_statement_lines
}
return self.env['report'].render(report_name, docargs)

202
bank_statement_reconciliation_summary/report/summary_report.xml

@ -0,0 +1,202 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<template id="summary_report">
<link rel='stylesheet' href='/web/static/lib/bootstrap/css/bootstrap.css'/>
<style>
.lines {
border-top: solid;
border-top-width: 2px;
border-top-color: #edf3f8;
color: #5993c0;
}
</style>
<t t-call="report.html_container">
<div class="page">
<div class='row' style='background-color: #e6ffe6;box-shadow: 0px 2px 2px #cccccc;'>
<div style='padding:5px;'>
<div class='col-xs-3'><h4>Date</h4></div>
<div class='col-xs-3'><h4>Description</h4></div>
<div class='col-xs-3'><h4>Reference</h4></div>
<div class='col-xs-3 text-right'><h4>Amount</h4></div>
</div>
</div>
<t t-foreach="docs" t-as="o">
<div class='row mt16'>
<div class='col-xs-12'><h5><b><t t-esc='o.journal_id.name'/> - Balance in Odoo</b></h5>
</div>
</div>
<t t-set='total_bank_odoo' t-value='0.00'/>
<div class='row lines'>
<div class='col-xs-12'>
<div class='col-xs-3'><t t-esc='o.date'/></div>
<div class='col-xs-3'><t
t-esc='o.journal_id.default_credit_account_id.code'/>-<t t-esc='o.journal_id.default_credit_account_id.name'/></div>
<div class='col-xs-3'/>
<t t-set='total_bank_odoo'
t-value='o.journal_id.default_credit_account_id.balance'/>
<div class='col-xs-3 text-right'><t
t-esc='total_bank_odoo'
t-esc-options='{"widget": "monetary", "display_currency": "o.currency"}'/></div>
</div>
</div>
<t t-set='total_clearing_odoo' t-value='0.00'/>
<div class='row lines'>
<div class='col-xs-12'>
<div class='col-xs-3'><t t-esc='o.date'/></div>
<div class='col-xs-3'>
<t t-esc='o.journal_id.default_credit_account_id.clearing_account_id.code'/>-<t t-esc='o.journal_id.default_credit_account_id.clearing_account_id.name'/></div>
<div class='col-xs-3'/>
<t t-set='total_clearing_odoo'
t-value='o.journal_id.default_credit_account_id.clearing_account_id.balance'/>
<div class='col-xs-3 text-right'>
<t t-esc='total_clearing_odoo'
t-esc-options='{"widget": "monetary", "display_currency": "o.currency"}'/></div>
</div>
</div>
<t t-set='total_bank_clearing_odoo' t-value='0.00'/>
<div class='row' style='border-top: groove;'>
<div class='col-xs-12'>
<div class='col-xs-6'><h5><b>Total Balance in Odoo</b></h5></div>
<div class='col-xs-3'/>
<t t-set='total_bank_clearing_odoo'
t-value='o.journal_id.default_credit_account_id.balance + o.journal_id.default_credit_account_id.clearing_account_id.balance'/>
<div class='col-xs-3 text-right'>
<h5><b>
<t t-esc='total_bank_clearing_odoo'
t-esc-options='{"widget": "monetary", "display_currency": "o.currency"}'/>
</b></h5></div>
</div>
</div>
<t t-set='total_payment' t-value='0.00'/>
<t t-if='plus_outstanding_payments(o.journal_id)'>
<div class='row mt16'>
<div class='col-xs-12'><h5><b>Plus Outstanding Payments</b></h5></div>
</div>
<t t-foreach='plus_outstanding_payments(o.journal_id)' t-as='payment'>
<div class='row lines'>
<div class='col-xs-12'>
<div class='col-xs-3'><t t-esc='payment.date'/></div>
<div class='col-xs-3'><t t-esc='payment.name'/></div>
<div class='col-xs-3'><t t-esc='payment.ref'/></div>
<div class='col-xs-3 text-right'><t t-esc='payment.credit'/></div>
<t t-set='total_payment' t-value='total_payment + payment.credit'
t-esc-options='{"widget": "monetary", "display_currency": "o.currency"}'/>
</div>
</div>
</t>
<div class='row' style='border-top: groove;'>
<div class='col-xs-12'>
<div class='col-xs-6'><h5><b>Total Outstanding Payments</b></h5></div>
<div class='col-xs-3 col-xs-offset-3 text-right'><h5><b><t t-esc='total_payment'
t-esc-options='{"widget": "monetary", "display_currency": "o.currency"}'/></b></h5></div>
</div>
</div>
</t>
<t t-set='total_receipt' t-value='0.00'/>
<t t-if='less_outstanding_receipts(o.journal_id)'>
<div class='row'>
<div class='col-xs-12'><h5><b>Less Outstanding Receipts</b></h5></div>
</div>
<t t-foreach='less_outstanding_receipts(o.journal_id)' t-as='receipt'>
<div class='row lines'>
<div class='col-xs-12'>
<div class='col-xs-3'><t t-esc='receipt.date'/></div>
<div class='col-xs-3'><t t-esc='receipt.name'/></div>
<div class='col-xs-3'><t t-esc='receipt.ref'/></div>
<div class='col-xs-3 text-right'><t t-esc='receipt.debit'/></div>
<t t-set='total_receipt' t-value='total_receipt + receipt.debit'
t-esc-options='{"widget": "monetary", "display_currency": "o.currency"}'/>
</div>
</div>
</t>
<div class='row' style='border-top: groove;'>
<div class='col-xs-12'>
<div class='col-xs-6'><h5><b>Total Outstanding Receipts</b></h5></div>
<div class='col-xs-3 col-xs-offset-3 text-right'><h5><b><t t-esc='total_receipt'
t-esc-options='{"widget": "monetary", "display_currency": "o.currency"}'/></b></h5></div>
</div>
</div>
</t>
<t t-set='bank_stmt_line_total' t-value='0.00'/>
<t t-if='plus_unreconciled_statement_lines(o)'>
<div class='row'>
<div class='col-xs-12'><h5><b>Plus Un-Reconciled Bank Statement Lines</b></h5></div>
</div>
<t t-foreach='plus_unreconciled_statement_lines(o)' t-as='line'>
<div class='row lines'>
<div class='col-xs-12'>
<div class='col-xs-3'><t t-esc='line.date'/></div>
<div class='col-xs-3'><t t-esc='line.name'/></div>
<div class='col-xs-3'><t t-esc='line.ref'/></div>
<div class='col-xs-3 text-right'><t t-esc='line.amount'
t-esc-options='{"widget": "monetary", "display_currency": "o.currency"}'/></div>
<t t-set='bank_stmt_line_total' t-value='bank_stmt_line_total + line.amount'
t-esc-options='{"widget": "monetary", "display_currency": "o.currency"}'/>
</div>
</div>
</t>
<div class='row' style='border-top: groove;'>
<div class='col-xs-12'>
<div class='col-xs-6'><h5><b>Total Un-Reconciled Bank Statement Lines</b></h5></div>
<div class='col-xs-3 col-xs-offset-3 text-right'><h5><b><t t-esc='bank_stmt_line_total'
t-esc-options='{"widget": "monetary", "display_currency": "o.currency"}'/></b></h5></div>
</div>
</div>
</t>
<t t-set='computed_statement_balance' t-value='total_bank_clearing_odoo + total_payment - total_receipt + bank_stmt_line_total'/>
<t t-if='(o.balance_end_real - computed_statement_balance) == 0.0'>
<div class='row mt8' style='border-top: solid;border-bottom: solid;'>
<div class='col-xs-3'><t t-esc='o.date'/></div>
<div class='col-xs-3'><h5><b>Statement Balance</b></h5></div>
<div class='col-xs-3'/>
<div class='col-xs-3 text-right'>
<t t-esc='computed_statement_balance'
t-esc-options='{"widget": "monetary", "display_currency": "o.currency"}'/></div>
</div>
</t>
<t t-if='(o.balance_end_real - computed_statement_balance) != 0.0'>
<div class='row mt16'>
<div class='col-xs-12'><h5><b>Statement Balance</b></h5>
</div>
</div>
<div class='row lines'>
<div class='col-xs-12'>
<div class='col-xs-3'><t t-esc='o.date'/></div>
<div class='col-xs-3'>Computed</div>
<div class='col-xs-3'/>
<div class='col-xs-3 text-right'>
<t t-esc='computed_statement_balance'
t-esc-options='{"widget": "monetary", "display_currency": "o.currency"}'/></div>
</div>
</div>
<div class='row lines'>
<div class='col-xs-12'>
<div class='col-xs-3'><t t-esc='o.date'/></div>
<div class='col-xs-3'>Actual</div>
<div class='col-xs-3'/>
<div class='col-xs-3 text-right'>
<t t-esc='o.balance_end_real'
t-esc-options='{"widget": "monetary", "display_currency": "o.currency"}'/></div>
</div>
</div>
<div class='row lines'>
<div class='col-xs-12'>
<div class='col-xs-3'><t t-esc='o.date'/></div>
<div class='col-xs-3'>Unencoded Statement Amount</div>
<div class='col-xs-3'/>
<div class='col-xs-3 text-right'>
<t t-esc='o.balance_end_real - computed_statement_balance'
t-esc-options='{"widget": "monetary", "display_currency": "o.currency"}'/></div>
</div>
</div>
</t>
</t>
</div>
</t>
</template>
</data>
</openerp>

17
bank_statement_reconciliation_summary/view/account_account_view.xml

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="view_account_form_inherit" model="ir.ui.view">
<field name="name">inherit.account.form</field>
<field name="model">account.account</field>
<field name="inherit_id" ref="account.view_account_form"/>
<field name="arch" type="xml">
<field name='active' position="after">
<field name="clearing_account_id"/>
</field>
</field>
</record>
</data>
</openerp>

34
bank_statement_reconciliation_summary/view/account_bank_statement.xml

@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<openerp>
<data>
<record id="unreconcile_bank_statement_form_view" model="ir.ui.view">
<field name="name">account.bank.statement.form.view</field>
<field name="model">account.bank.statement</field>
<field name="inherit_id" ref="account.view_bank_statement_form"/>
<field name="arch" type="xml">
<button string="Import Invoice" position="before">
<button type="action"
class="oe_inline oe_stat_button"
id="wiz_unreconcile"
icon="fa-pencil-square-o"
name="%(bank_statement_reconcile_action)d"
attrs="{'invisible': [('state', '!=', 'draft')]}"
style="width: 180px !important;">
<div>Import<br/>Payments and Receipts</div>
</button>
<button type="object"
class="oe_inline oe_stat_button"
id="wiz_unreconcile"
icon="fa-strikethrough"
name="delete_unreconciled"
attrs="{'invisible': [('state', '=', 'confirm')]}"
style="width: 180px !important;">
<div>Remove Unreconciled</div>
</button>
</button>
</field>
</record>
</data>
</openerp>

5
bank_statement_reconciliation_summary/wizard/__init__.py

@ -0,0 +1,5 @@
# -*- coding: utf-8 -*-
# © 2016 Eficent Business and IT Consulting Services S.L.
# © 2016 Serpent Consulting Services Pvt. Ltd.
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
import account_bank_unreconcile

93
bank_statement_reconciliation_summary/wizard/account_bank_unreconcile.py

@ -0,0 +1,93 @@
# -*- coding: utf-8 -*-
# © 2016 Eficent Business and IT Consulting Services S.L.
# © 2016 Serpent Consulting Services Pvt. Ltd.
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from openerp import api, fields, models
from openerp.tools import misc
from openerp.exceptions import Warning
from openerp.tools.translate import _
class SummaryReport(models.TransientModel):
_name = 'wiz.bank.unreconcile'
@api.model
def _get_unreconcile_entries(self):
cr, uid, context = self.env.args
context = dict(context)
statement_line_obj = self.env['account.bank.statement.line']
move_line_obj = self.env['account.move.line']
bank_id = context.get('active_id')
self.env.args = cr, uid, misc.frozendict(context)
bank = self.env['account.bank.statement'].browse(bank_id)
clearing_account_id = bank.journal_id and\
bank.journal_id.default_credit_account_id and\
bank.journal_id.default_credit_account_id.clearing_account_id and\
bank.journal_id.default_credit_account_id.clearing_account_id.id
if clearing_account_id:
to_add_move_lines = move_line_obj.browse()
account_move_line_records = self.env['account.move.line'].search([
('account_id', '=', clearing_account_id),
('account_id.reconcile', '=', True),
'|',
('reconcile_id', '=', False),
('reconcile_partial_id', '!=', False)
], order='date')
statements = statement_line_obj.search(
[('statement_id', '=', bank_id),
('clearing_move_line_id', 'in',
account_move_line_records.ids)])
in_statement_clearing_lines = []
for statement in statements:
in_statement_clearing_lines += \
statement.clearing_move_line_id
for move_line in account_move_line_records:
if move_line not in in_statement_clearing_lines:
to_add_move_lines += move_line
else:
raise Warning(_("Create an Clearing Account to get "
"the Unreconciled Journal Items."))
return to_add_move_lines
line_ids = fields.Many2many('account.move.line',
'wiz_unreconciles_move_line_rel',
'reconciles_id', 'accounts_id',
'Journal Items to Reconcile',
default=_get_unreconcile_entries)
@api.multi
def process_wiz(self):
context = dict(self._context)
bank_stmt_obj = self.env['account.bank.statement']
currency_obj = self.env['res.currency']
statement = bank_stmt_obj.browse(context.get('active_ids'))
lines = []
for line in self.line_ids:
currency_obj = currency_obj.with_context(date=statement.date)
amount = 0.0
if line.debit > 0:
amount = line.debit
elif line.credit > 0:
amount = -line.credit
if line.amount_currency:
if line.company_id.currency_id.id != statement.currency.id:
amount = line.currency_id.with_context(
date=statement.date).compute(line.amount_currency,
statement.currency)
elif (line.currency_id and
line.currency_id.id != statement.currency.id):
amount = line.currency_id.with_context(
date=statement.date).compute(amount,
statement.currency)
lines.append((0, 0, {
'name': line.name or '?',
'ref': line.ref,
'partner_id': line.partner_id.id,
'amount': amount,
'date': line.date,
'amount_currency': line.amount_currency,
'currency_id': line.currency_id.id,
'clearing_move_line_id': line.id,
}))
statement.write({'line_ids': lines})
return True

30
bank_statement_reconciliation_summary/wizard/account_bank_unreconcile_view.xml

@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<openerp>
<data>
<record id="account_bank_reconcile_form_view" model="ir.ui.view">
<field name="name">wiz.bank.unreconcile.form</field>
<field name="model">wiz.bank.unreconcile</field>
<field name="arch" type="xml">
<form string="Import">
<field name="line_ids"
context="{'currency':True}"/>
<footer>
<button name="process_wiz" string="Import" type="object" class="oe_highlight"/>
or
<button string="Cancel" class="oe_link" special="cancel"/>
</footer>
</form>
</field>
</record>
<act_window name="Unreconcile Journal Items"
res_model="wiz.bank.unreconcile"
src_model="account.bank.statement"
view_mode="form"
view_type="form"
target="new"
id="bank_statement_reconcile_action"/>
</data>
</openerp>
Loading…
Cancel
Save