[10.0][FIX] prevent assigning parner with default ref

This commit is contained in:
Iryna Vushnevska
2019-09-06 15:10:05 +03:00
committed by Iryna Vyshnevska
parent f4a620de47
commit 176d598741
4 changed files with 44 additions and 0 deletions

View File

@@ -1,3 +1,5 @@
from . import parser from . import parser
from . import account_bank_statement_import from . import account_bank_statement_import
from . import account_journal from . import account_journal
from . import bank_statement
from . import account_bank_statement_line

View File

@@ -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)

View File

@@ -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()

View File

@@ -3,3 +3,4 @@
* Ronald Portier <rportier@therp.nl> * Ronald Portier <rportier@therp.nl>
* Andrea Stirpe <a.stirpe@onestein.nl> * Andrea Stirpe <a.stirpe@onestein.nl>
* Maxence Groine <mgroine@fiefmanage.ch> * Maxence Groine <mgroine@fiefmanage.ch>
* Iryna Vyshnevska <i.vyshnevska@mobilunity.com>