Browse Source

CAMT import & reconciliation: Try to find a match using the statement line 'ref' field

pull/182/head
Maxence Groine 6 years ago
parent
commit
f281985b3c
  1. 2
      account_bank_statement_import_camt_oca/__manifest__.py
  2. 1
      account_bank_statement_import_camt_oca/models/__init__.py
  3. 43
      account_bank_statement_import_camt_oca/models/account_bank_statement_line.py

2
account_bank_statement_import_camt_oca/__manifest__.py

@ -2,7 +2,7 @@
# 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).
{ {
'name': 'CAMT Format Bank Statements Import', 'name': 'CAMT Format Bank Statements Import',
'version': '11.0.1.0.2',
'version': '11.0.1.0.3',
'license': 'AGPL-3', 'license': 'AGPL-3',
'author': 'Odoo Community Association (OCA), Therp BV', 'author': 'Odoo Community Association (OCA), Therp BV',
'website': 'https://github.com/OCA/bank-statement-import', 'website': 'https://github.com/OCA/bank-statement-import',

1
account_bank_statement_import_camt_oca/models/__init__.py

@ -2,3 +2,4 @@
# 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 . import parser from . import parser
from . import account_bank_statement_import from . import account_bank_statement_import
from . import account_bank_statement_line

43
account_bank_statement_import_camt_oca/models/account_bank_statement_line.py

@ -0,0 +1,43 @@
from odoo import models
class AccountBankStatementLine(models.Model):
_inherit = "account.bank.statement.line"
def get_reconciliation_proposition(self, excluded_ids=None):
""" Overridden to try & identify a reconciliation move_line for the
current statement line by using the reference to match a bank
payment line.
This works in the case where the bank_payment_line
`communication_type` is set to 'normal', as we then get the CAMT
Ntry's `EndToEndId` value in self.ref after parsing, which is the
Odoo bank_payment_line name if the related pain.001 file was
emitted through the OCA's bank-payment flow.
"""
self.ensure_one()
if not excluded_ids:
excluded_ids = []
sql_query = """
SELECT aml.id
FROM account_move_line aml
JOIN account_payment_line apl ON apl.move_line_id = aml.id
JOIN bank_payment_line bpl ON bpl.id = apl.bank_line_id
WHERE bpl.name = %(ref)s
"""
if excluded_ids:
sql_query = sql_query + ' AND aml.id NOT IN %(excluded_ids)s'
params = {
'ref': self.ref,
'excluded_ids': tuple(excluded_ids),
}
self.env.cr.execute(sql_query, params)
results = self.env.cr.fetchone()
if results:
return self.env['account.move.line'].browse(results[0])
return super().get_reconciliation_proposition(excluded_ids)
Loading…
Cancel
Save