Skip to content

Commit

Permalink
Merge e134acb into 0964eb4
Browse files Browse the repository at this point in the history
  • Loading branch information
AaronHForgeFlow committed Sep 5, 2019
2 parents 0964eb4 + e134acb commit 27f89fe
Show file tree
Hide file tree
Showing 6 changed files with 161 additions and 0 deletions.
55 changes: 55 additions & 0 deletions account_bank_reconcile_hook/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
.. image:: https://img.shields.io/badge/licence-LGPL--3-blue.svg
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
:alt: License: LGPL-3

===========================
Account Bank Reconcile Hook
===========================

This module does nothing by itself. It adds the possibility to another module
to change the criteria for fetching the bank lines for the bank statement.


Usage
=====


.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
:alt: Try me on Runbot
:target: https://runbot.odoo-community.org/runbot/98/10.0

Bug Tracker
===========

Bugs are tracked on `GitHub Issues
<https://github.com/OCA/bank-statement-reconcile/issues>`_. In case of trouble, please
check there if your issue has already been reported. If you spotted it first,
help us smash it by providing detailed and welcomed feedback.

Credits
=======

Images
------

* Odoo Community Association: `Icon <https://github.com/OCA/maintainer-tools/blob/master/template/module/static/description/icon.svg>`_.

Contributors
------------

* Odoo SA

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.
3 changes: 3 additions & 0 deletions account_bank_reconcile_hook/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# -*- coding: utf-8 -*-

from . import models
16 changes: 16 additions & 0 deletions account_bank_reconcile_hook/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# -*- coding: utf-8 -*-
# Copyright 2018 Odoo SA
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).
{
"name": "Bank Reconciliation Threshold",
"version": "10.0.1.0.0",
"license": "LGPL-3",
"category": "Accounting and Financial Management",
"author": 'Odoo SA,'
'Odoo Community Association (OCA)',
"website": "https://github.com/OCA/account-reconcile",
"depends": [
"account",
],
"installable": True,
}
3 changes: 3 additions & 0 deletions account_bank_reconcile_hook/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# -*- coding: utf-8 -*-

from . import account_bank_statement_line
84 changes: 84 additions & 0 deletions account_bank_reconcile_hook/models/account_bank_statement_line.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# -*- coding: utf-8 -*-
# Copyright 2018 Odoo SA
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).
from odoo import models
from odoo.osv import expression


class AccountBankStatementLine(models.Model):

_inherit = 'account.bank.statement.line'

def get_move_lines_for_reconciliation(self, excluded_ids=None, str=False,
offset=0, limit=None,
additional_domain=None,
overlook_partner=False):
""" Return account.move.line records which can be used for bank
statement reconciliation.
:param excluded_ids:
:param str:
:param offset:
:param limit:
:param additional_domain:
:param overlook_partner:
"""
# Blue lines = payment on bank account not assigned to a statement yet
domain_reconciliation = self._get_domain_reconciliation()

# Black lines = unreconciled & (not linked to a payment or open
# balance created by statement
domain_matching = [('reconciled', '=', False)]
if self.partner_id.id or overlook_partner:
domain_matching = expression.AND([domain_matching, [
('account_id.internal_type', 'in',
['payable', 'receivable'])]])
else:
# TODO : find out what use case this permits (match a check
# payment, registered on a journal whose account type is other
# instead of liquidity)
domain_matching = expression.AND(
[domain_matching, [('account_id.reconcile', '=', True)]])

# Let's add what applies to both
domain = expression.OR([domain_reconciliation, domain_matching])
if self.partner_id.id and not overlook_partner:
domain = expression.AND(
[domain, [('partner_id', '=', self.partner_id.id)]])

# Domain factorized for all reconciliation use cases
ctx = dict(self._context or {})
ctx['bank_statement_line'] = self
generic_domain = self.env['account.move.line'].with_context(
ctx).domain_move_lines_for_reconciliation(
excluded_ids=excluded_ids, str=str)
domain = expression.AND([domain, generic_domain])

# Domain from caller
if additional_domain is None:
additional_domain = []
else:
additional_domain = expression.normalize_domain(additional_domain)
domain = expression.AND([domain, additional_domain])

domain = self._get_final_domain(domain)

return self.env['account.move.line'].search(
domain, offset=offset,
limit=limit,
order="date_maturity asc, id asc")

def _get_domain_reconciliation(self):
reconciliation_aml_accounts = [
self.journal_id.default_credit_account_id.id,
self.journal_id.default_debit_account_id.id]
domain_reconciliation = ['&',
('statement_id', '=', False),
('account_id', 'in',
reconciliation_aml_accounts)]
return domain_reconciliation

def _get_final_domain(self, domain):
""" This allows to edit the final domain since, from the previous hook,
the domain is altered in many ways """
return domain
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 27f89fe

Please sign in to comment.