Search also on BIC when searching bank name
and remove starting wildcard when searching account number issue11135 review384071002
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
* Remove starting wildcard when searching account number
|
||||
* Search also on BIC when searching bank name
|
||||
* Add support for Python 3.10
|
||||
* Remove support for Python 3.6
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ from stdnum import bic, iban
|
||||
from trytond.i18n import gettext
|
||||
from trytond.model import (
|
||||
DeactivableMixin, ModelSQL, ModelView, fields, sequence_ordered)
|
||||
from trytond.tools import lstrip_wildcard
|
||||
|
||||
from .exceptions import IBANValidationError, InvalidBIC
|
||||
|
||||
@@ -23,7 +24,17 @@ class Bank(ModelSQL, ModelView):
|
||||
|
||||
@classmethod
|
||||
def search_rec_name(cls, name, clause):
|
||||
return [('party.rec_name',) + tuple(clause[1:])]
|
||||
if clause[1].startswith('!') or clause[1].startswith('not '):
|
||||
bool_op = 'AND'
|
||||
else:
|
||||
bool_op = 'OR'
|
||||
bic_value = clause[2]
|
||||
if clause[1].endswith('like'):
|
||||
bic_value = lstrip_wildcard(clause[2])
|
||||
return [bool_op,
|
||||
('party.rec_name',) + tuple(clause[1:]),
|
||||
('bic', clause[1], bic_value) + tuple(clause[3:]),
|
||||
]
|
||||
|
||||
@fields.depends('bic')
|
||||
def on_change_with_bic(self):
|
||||
@@ -128,6 +139,19 @@ class AccountNumber(sequence_ordered(), ModelSQL, ModelView):
|
||||
return (iban.compact(self.number) if self.type == 'iban'
|
||||
else self.number)
|
||||
|
||||
@classmethod
|
||||
def search_rec_name(cls, name, clause):
|
||||
if clause[1].startswith('!') or clause[1].startswith('not '):
|
||||
bool_op = 'AND'
|
||||
else:
|
||||
bool_op = 'OR'
|
||||
number_value = clause[2]
|
||||
if clause[1].endswith('like'):
|
||||
number_value = lstrip_wildcard(clause[2])
|
||||
return [bool_op,
|
||||
('number', clause[1], number_value) + tuple(clause[3:]),
|
||||
]
|
||||
|
||||
@classmethod
|
||||
def create(cls, vlist):
|
||||
vlist = [v.copy() for v in vlist]
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
# this repository contains the full copyright notices and license terms.
|
||||
from trytond.model import fields
|
||||
from trytond.pool import PoolMeta
|
||||
from trytond.tools import lstrip_wildcard
|
||||
from trytond.transaction import Transaction
|
||||
|
||||
|
||||
@@ -18,13 +17,9 @@ class Party(metaclass=PoolMeta):
|
||||
bool_op = 'AND'
|
||||
else:
|
||||
bool_op = 'OR'
|
||||
code_value = clause[2]
|
||||
if clause[1].endswith('like'):
|
||||
code_value = lstrip_wildcard(clause[2])
|
||||
return [bool_op,
|
||||
domain,
|
||||
('bank_accounts.numbers.rec_name',
|
||||
clause[1], code_value) + tuple(clause[3:]),
|
||||
('bank_accounts.numbers.rec_name',) + tuple(clause[1:]),
|
||||
]
|
||||
|
||||
@classmethod
|
||||
|
||||
Reference in New Issue
Block a user