From 176d598741c9401968d574205705abed5488c110 Mon Sep 17 00:00:00 2001 From: Iryna Vushnevska Date: Fri, 6 Sep 2019 15:10:05 +0300 Subject: [PATCH] [10.0][FIX] prevent assigning parner with default ref --- .../models/__init__.py | 2 ++ .../models/account_bank_statement_line.py | 28 +++++++++++++++++++ .../models/bank_statement.py | 13 +++++++++ .../readme/CONTRIBUTORS.rst | 1 + 4 files changed, 44 insertions(+) create mode 100644 account_bank_statement_import_camt_oca/models/account_bank_statement_line.py create mode 100644 account_bank_statement_import_camt_oca/models/bank_statement.py diff --git a/account_bank_statement_import_camt_oca/models/__init__.py b/account_bank_statement_import_camt_oca/models/__init__.py index a1ecc881..db3c4e5c 100644 --- a/account_bank_statement_import_camt_oca/models/__init__.py +++ b/account_bank_statement_import_camt_oca/models/__init__.py @@ -1,3 +1,5 @@ from . import parser from . import account_bank_statement_import from . import account_journal +from . import bank_statement +from . import account_bank_statement_line diff --git a/account_bank_statement_import_camt_oca/models/account_bank_statement_line.py b/account_bank_statement_import_camt_oca/models/account_bank_statement_line.py new file mode 100644 index 00000000..823490f3 --- /dev/null +++ b/account_bank_statement_import_camt_oca/models/account_bank_statement_line.py @@ -0,0 +1,28 @@ +# 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_oca/models/bank_statement.py b/account_bank_statement_import_camt_oca/models/bank_statement.py new file mode 100644 index 00000000..72dc5c01 --- /dev/null +++ b/account_bank_statement_import_camt_oca/models/bank_statement.py @@ -0,0 +1,13 @@ +# 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_oca/readme/CONTRIBUTORS.rst b/account_bank_statement_import_camt_oca/readme/CONTRIBUTORS.rst index e10c70b8..32d01b27 100644 --- a/account_bank_statement_import_camt_oca/readme/CONTRIBUTORS.rst +++ b/account_bank_statement_import_camt_oca/readme/CONTRIBUTORS.rst @@ -3,3 +3,4 @@ * Ronald Portier * Andrea Stirpe * Maxence Groine +* Iryna Vyshnevska