Search also on BIC when searching bank name

and remove starting wildcard when searching account number

issue11135
review384071002
This commit is contained in:
Cédric Krier
2022-01-30 13:00:50 +01:00
parent c2ecf0b798
commit 7419421e61
3 changed files with 28 additions and 7 deletions
+2
View File
@@ -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
+25 -1
View File
@@ -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]
+1 -6
View File
@@ -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