Compare commits
2 Commits
1edc5c2b02
...
28c2b8a9dd
Author | SHA1 | Date |
---|---|---|
Raimon Esteve | 28c2b8a9dd | |
Raimon Esteve | 78a885d986 |
|
@ -27,6 +27,7 @@ def register():
|
|||
Pool.register(
|
||||
bank.Bank,
|
||||
bank.BankAccount,
|
||||
bank.BankAccountNumber,
|
||||
depends=['bank'],
|
||||
module='party_company', type_='model')
|
||||
Pool.register(
|
||||
|
|
20
bank.py
20
bank.py
|
@ -3,6 +3,7 @@
|
|||
from trytond.model import fields
|
||||
from trytond.pool import Pool, PoolMeta
|
||||
from trytond.transaction import Transaction
|
||||
from trytond import backend
|
||||
from . import party
|
||||
|
||||
|
||||
|
@ -59,3 +60,22 @@ class BankAccount(metaclass=PoolMeta):
|
|||
@classmethod
|
||||
def set_owners_by_companies(cls, records, name, value):
|
||||
cls.write(records, {'owners': value})
|
||||
|
||||
|
||||
class BankAccountNumber(metaclass=PoolMeta):
|
||||
__name__ = 'bank.account.number'
|
||||
|
||||
@classmethod
|
||||
def __register__(cls, module_name):
|
||||
cursor = Transaction().connection.cursor()
|
||||
|
||||
# since issue11198 fill or create bank from IBAN and enforce uniqueness
|
||||
# replace default sql_constrain (keep same name) that always return false
|
||||
exist = backend.TableHandler.table_exist(cls._table)
|
||||
if exist and backend.name == 'postgresql':
|
||||
cursor.execute("ALTER TABLE bank_account_number DROP CONSTRAINT "
|
||||
"IF EXISTS bank_account_number_number_iban_exclude")
|
||||
cursor.execute("ALTER table bank_account_number add constraint "
|
||||
"bank_account_number_number_iban_exclude check (type != 'x')")
|
||||
|
||||
super(BankAccountNumber, cls).__register__(module_name)
|
||||
|
|
Loading…
Reference in New Issue