Holger Brunn
8 years ago
No known key found for this signature in database
GPG Key ID: 1C9760FECA3AE18
7 changed files with 121 additions and 33 deletions
-
8account_bank_statement_import_auto_reconcile/README.rst
-
1account_bank_statement_import_auto_reconcile/__openerp__.py
-
3account_bank_statement_import_auto_reconcile/models/__init__.py
-
50account_bank_statement_import_auto_reconcile/models/account_bank_statement_import_auto_reconcile.py
-
71account_bank_statement_import_auto_reconcile/models/account_bank_statement_import_auto_reconcile_exact_amount.py
-
20account_bank_statement_import_auto_reconcile/models/account_bank_statement_import_auto_reconcile_odoo.py
-
1oca_dependencies.txt
@ -1,45 +1,52 @@ |
|||||
# -*- coding: utf-8 -*- |
# -*- coding: utf-8 -*- |
||||
# © 2017 Therp BV <http://therp.nl> |
# © 2017 Therp BV <http://therp.nl> |
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). |
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). |
||||
from openerp import api, models |
|
||||
from openerp.tools import float_compare |
|
||||
|
from openerp import api, fields, models |
||||
|
|
||||
|
|
||||
class AccountBankStatementImportAutoReconcileExactAmount(models.AbstractModel): |
class AccountBankStatementImportAutoReconcileExactAmount(models.AbstractModel): |
||||
_inherit = 'account.bank.statement.import.auto.reconcile' |
_inherit = 'account.bank.statement.import.auto.reconcile' |
||||
_name = 'account.bank.statement.import.auto.reconcile.exact.amount' |
_name = 'account.bank.statement.import.auto.reconcile.exact.amount' |
||||
_description = 'Exact match on amount' |
|
||||
|
_description = 'Exact partner, amount and reference' |
||||
|
|
||||
|
substring_match = fields.Boolean('Match for substrings', default=False) |
||||
|
case_sensitive = fields.Boolean('Case sensitive matching', default=False) |
||||
|
|
||||
@api.multi |
@api.multi |
||||
def reconcile(self, statement_line): |
def reconcile(self, statement_line): |
||||
"""Find an open invoice for the statement line's partner""" |
|
||||
# TODO: this is the lazy version, searching a bit more specialized |
|
||||
# and with some caching should speed this up a lot |
|
||||
matches = statement_line.get_reconciliation_proposition(statement_line) |
|
||||
digits = self.env['decimal.precision'].precision_get('Account') |
|
||||
if len(matches) == 1 and ( |
|
||||
float_compare( |
|
||||
matches[0]['debit'], statement_line.amount, |
|
||||
precision_digits=digits |
|
||||
) == 0 or |
|
||||
float_compare( |
|
||||
-matches[0]['credit'], statement_line.amount, |
|
||||
precision_digits=digits |
|
||||
) == 0 |
|
||||
|
if not statement_line.partner_id or ( |
||||
|
not statement_line.ref and not statement_line.name |
||||
): |
): |
||||
move = self.env['account.move'].create( |
|
||||
self.env['account.bank.statement']._prepare_move( |
|
||||
statement_line, |
|
||||
( |
|
||||
statement_line.statement_id.name or statement_line.name |
|
||||
) + "/" + str(statement_line.sequence or '') |
|
||||
) |
|
||||
) |
|
||||
move_line_dict = self.env['account.bank.statement']\ |
|
||||
._prepare_bank_move_line( |
|
||||
statement_line, move.id, -statement_line.amount, |
|
||||
statement_line.statement_id.company_id.currency_id.id, |
|
||||
) |
|
||||
move_line_dict['counterpart_move_line_id'] = matches[0]['id'] |
|
||||
statement_line.process_reconciliation([move_line_dict]) |
|
||||
|
return |
||||
|
|
||||
|
operator = '=ilike' |
||||
|
if self.substring_match: |
||||
|
operator = 'substring_of' |
||||
|
elif self.case_sensitive: |
||||
|
operator = '=like' |
||||
|
|
||||
|
amount_field = 'debit' |
||||
|
sign = 1 |
||||
|
if statement_line.currency_id or statement_line.journal_id.currency: |
||||
|
if statement_line.amount < 0: |
||||
|
amount_field = 'credit' |
||||
|
sign = -1 |
||||
|
else: |
||||
|
amount_field = 'amount_currency' |
||||
|
|
||||
|
domain = [ |
||||
|
'|', '|', '|', |
||||
|
('ref', operator, statement_line.ref), |
||||
|
('name', operator, statement_line.name), |
||||
|
('ref', operator, statement_line.name), |
||||
|
('name', operator, statement_line.ref), |
||||
|
('reconcile_id', '=', False), |
||||
|
('state', '=', 'valid'), |
||||
|
('account_id.reconcile', '=', True), |
||||
|
('partner_id', '=', statement_line.partner_id.id), |
||||
|
(amount_field, '=', self._round(sign * statement_line.amount)), |
||||
|
] |
||||
|
move_lines = self.env['account.move.line'].search(domain, limit=1) |
||||
|
if move_lines: |
||||
|
self._reconcile_move_line(statement_line, move_lines.id) |
||||
return True |
return True |
@ -0,0 +1,20 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
# © 2017 Therp BV <http://therp.nl> |
||||
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). |
||||
|
from openerp import api, models |
||||
|
|
||||
|
|
||||
|
class AccountBankStatementImportAutoReconcileOdoo(models.AbstractModel): |
||||
|
_inherit = 'account.bank.statement.import.auto.reconcile' |
||||
|
_name = 'account.bank.statement.import.auto.reconcile.odoo' |
||||
|
_description = 'Odoo standard' |
||||
|
|
||||
|
@api.multi |
||||
|
def reconcile(self, statement_line): |
||||
|
"""Find an open invoice for the statement line's partner""" |
||||
|
matches = statement_line.get_reconciliation_proposition(statement_line) |
||||
|
if len(matches) == 1 and self._matches_amount( |
||||
|
statement_line, matches[0]['debit'], -matches[0]['credit'], |
||||
|
): |
||||
|
self._reconcile_move_line(statement_line, matches[0]['id']) |
||||
|
return True |
@ -1,3 +1,4 @@ |
|||||
# list the OCA project dependencies, one per line |
# list the OCA project dependencies, one per line |
||||
# add a github url if you need a forked version |
# add a github url if you need a forked version |
||||
web |
web |
||||
|
server-tools |
Write
Preview
Loading…
Cancel
Save
Reference in new issue