-
Notifications
You must be signed in to change notification settings - Fork 1
/
party.py
148 lines (125 loc) · 4.45 KB
/
party.py
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
# For copyright and license terms, see COPYRIGHT.rst (top level of repository)
# Repository: https://github.com/C3S/collecting_society
import uuid
from trytond.model import ModelView, ModelSQL, fields, Unique
from trytond.pool import PoolMeta, Pool
from trytond.transaction import Transaction
from .collecting_society import MixinIdentifier
__all__ = [
'Party',
'PartyIdentifier',
'PartyIdentifierSpace',
'PartyCategory',
'ContactMechanism',
'Category',
'Address'
]
class Party(metaclass=PoolMeta):
__name__ = 'party.party'
_history = True
web_user = fields.One2One(
'web.user-party.party', 'party', 'user', 'Web User',
help='The web user of the party')
member_c3s = fields.Boolean('Member of C3S')
member_c3s_token = fields.Char('C3S Membership Token')
artists = fields.One2Many('artist', 'party', 'Artists')
default_solo_artist = fields.Many2One(
'artist', 'Default Solo Artist',
help='The default solo artist of this party')
firstname = fields.Char('Firstname')
lastname = fields.Char('Lastname')
birthdate = fields.Date('Birth Date')
repertoire_terms_accepted = fields.Boolean(
'Terms of Service Acceptance for Repertoire')
oid = fields.Char(
'OID', required=True,
help='A unique object identifier used in the public web api to avoid'
'exposure of implementation details to the users.')
cs_identifiers = fields.One2Many(
'party.cs_identifier', 'party', '3rd-Party Identifier',
help='The identifiers of the party')
legal_person = fields.Boolean('Legal Person')
common_public_interest = fields.Selection(
[
('no', 'No'),
('on_approval', 'On Approval'),
('approved', 'Approved'),
('rejected', 'Rejected'),
], 'Common Public Interest', required=True, sort=False)
@classmethod
def __setup__(cls):
super(Party, cls).__setup__()
table = cls.__table__()
cls._sql_constraints += [
('uuid_oid', Unique(table, table.oid),
'The OID of the client must be unique.'),
]
@staticmethod
def default_oid():
return str(uuid.uuid4())
@staticmethod
def default_common_public_interest():
return 'no'
@staticmethod
def default_account_receivable(**pattern):
company = pattern.get('company') or \
Transaction().context.get('company')
pool = Pool()
Account = pool.get('account.account')
accounts = Account.search([
('closed', '!=', True),
('type.receivable', '=', True),
('party_required', '=', True),
('company', '=', company),
])
if accounts:
return accounts[0]
@staticmethod
def default_account_payable(**pattern):
company = pattern.get('company') or \
Transaction().context.get('company')
pool = Pool()
Account = pool.get('account.account')
accounts = Account.search([
('closed', '!=', True),
('type.payable', '=', True),
('party_required', '=', True),
('company', '=', company),
])
if accounts:
return accounts[0]
@staticmethod
def default_customer_payment_term(**pattern):
pool = Pool()
PaymentTerm = pool.get('account.invoice.payment_term')
payment_terms = PaymentTerm.search([])
if payment_terms:
return payment_terms[0]
class PartyIdentifier(ModelSQL, ModelView, MixinIdentifier):
'Party Identifier'
__name__ = 'party.cs_identifier'
_history = True
space = fields.Many2One(
'party.cs_identifier.space', 'Party Identifier Name',
required=True, ondelete='CASCADE')
party = fields.Many2One(
'party.party', 'Party',
required=True, ondelete='CASCADE')
class PartyIdentifierSpace(ModelSQL, ModelView):
'Party Identifier Space'
__name__ = 'party.cs_identifier.space'
_history = True
name = fields.Char('Name of the ID space')
version = fields.Char('Version')
class PartyCategory(metaclass=PoolMeta):
__name__ = 'party.party-party.category'
_history = True
class ContactMechanism(metaclass=PoolMeta):
__name__ = 'party.contact_mechanism'
_history = True
class Category(metaclass=PoolMeta):
__name__ = 'party.category'
_history = True
class Address(metaclass=PoolMeta):
__name__ = 'party.address'
_history = True