This repository was archived by the owner on Dec 30, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathparty.py
More file actions
47 lines (40 loc) · 1.54 KB
/
Copy pathparty.py
File metadata and controls
47 lines (40 loc) · 1.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# This file is part of Tryton. The COPYRIGHT file at the top level of
# this repository contains the full copyright notices and license terms.
from trytond.model import fields
from trytond.pool import PoolMeta
from trytond.transaction import Transaction
class Party(metaclass=PoolMeta):
__name__ = 'party.party'
bank_accounts = fields.Many2Many(
'bank.account-party.party', 'owner', 'account', "Bank Accounts",
filter=[('active', '=', True)])
@classmethod
def search_rec_name(cls, name, clause):
domain = super(Party, cls).search_rec_name(name, clause)
if clause[1].startswith('!') or clause[1].startswith('not '):
bool_op = 'AND'
else:
bool_op = 'OR'
return [bool_op,
domain,
('bank_accounts.numbers.rec_name',) + tuple(clause[1:]),
]
@classmethod
def copy(cls, parties, default=None):
context = Transaction().context
default = default.copy() if default else {}
if context.get('_check_access'):
default.setdefault(
'bank_accounts',
cls.default_get(
['bank_accounts'],
with_rec_name=False).get('bank_accounts'))
return super().copy(parties, default=default)
class Replace(metaclass=PoolMeta):
__name__ = 'party.replace'
@classmethod
def fields_to_replace(cls):
return super().fields_to_replace() + [
('bank', 'party'),
('bank.account-party.party', 'owner'),
]