diff --git a/account_bank_statement_import_camt/models/__init__.py b/account_bank_statement_import_camt/models/__init__.py index 0251c8f17..b16466062 100644 --- a/account_bank_statement_import_camt/models/__init__.py +++ b/account_bank_statement_import_camt/models/__init__.py @@ -3,3 +3,5 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). from . import parser from . import account_bank_statement_import +from . import bank_statement +from . import account_bank_statement_line diff --git a/account_bank_statement_import_camt/models/account_bank_statement_line.py b/account_bank_statement_import_camt/models/account_bank_statement_line.py new file mode 100644 index 000000000..3f5f26a96 --- /dev/null +++ b/account_bank_statement_import_camt/models/account_bank_statement_line.py @@ -0,0 +1,29 @@ +# -*- coding: utf-8 -*- +# Copyright 2019 Camptocamp SA +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +from odoo import api, models + + +class AccountBankStatementLine(models.Model): + + _inherit = "account.bank.statement.line" + + @api.multi + def write(self, vals): + """ + Purpose of this hook is catch updates for records with name == '/' + + In reconciliation_widget_preprocess, there is attempt to assign + partner into statement line, this assignment relies on name, + during import name setup to '/' for records without it + and this makes search results wrong and partner assignment randomly + """ + if ( + self.env.context.get('no_reassign_empty_name') + and len(self) == 1 + and len(vals.keys()) == 1 + and 'partner_id' in vals + and self.name == '/' + ): + return True + return super(AccountBankStatementLine, self).write(vals) diff --git a/account_bank_statement_import_camt/models/bank_statement.py b/account_bank_statement_import_camt/models/bank_statement.py new file mode 100644 index 000000000..e54a92395 --- /dev/null +++ b/account_bank_statement_import_camt/models/bank_statement.py @@ -0,0 +1,14 @@ +# -*- coding: utf-8 -*- +# Copyright 2019 Camptocamp SA +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +from odoo import api, models + + +class AccountBankStatement(models.Model): + + _inherit = "account.bank.statement" + + @api.multi + def reconciliation_widget_preprocess(self): + return super(AccountBankStatement, self.with_context( + no_reassign_empty_name=True)).reconciliation_widget_preprocess() diff --git a/account_bank_statement_import_camt/tests/test_import_bank_statement.py b/account_bank_statement_import_camt/tests/test_import_bank_statement.py index 39e551e8d..769081528 100644 --- a/account_bank_statement_import_camt/tests/test_import_bank_statement.py +++ b/account_bank_statement_import_camt/tests/test_import_bank_statement.py @@ -31,7 +31,7 @@ def _do_parse_test(self, inputfile, goldenfile): temp.seek(0) diff = list( difflib.unified_diff(golden.readlines(), temp.readlines(), - golden.name, temp.name)) + golden.name, temp.name)) if len(diff) > 2: self.fail( "actual output doesn't match exptected output:\n%s" %