Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[10.0][FIX] prevent assigning parner with default name #224

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions account_bank_statement_import_camt/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
@@ -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)
14 changes: 14 additions & 0 deletions account_bank_statement_import_camt/models/bank_statement.py
Original file line number Diff line number Diff line change
@@ -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()
Original file line number Diff line number Diff line change
Expand Up @@ -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" %
Expand Down