Skip to content

Commit

Permalink
[10.0][FIX] prevent assigning parner with default ref
Browse files Browse the repository at this point in the history
  • Loading branch information
Iryna Vushnevska committed Sep 6, 2019
1 parent 8279ad6 commit f77ef30
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 0 deletions.
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
"""
recordset = self
if self.env.context.get('no_reassign_empty_ref'):
for rec in self:
if (len(vals.keys()) == 1 and 'partner_id' in vals
and rec.name == '/'
):
recordset -= rec
return super(AccountBankStatementLine, recordset).write(vals)
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_ref=True)).reconciliation_widget_preprocess()

0 comments on commit f77ef30

Please sign in to comment.