-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathparty.py
More file actions
157 lines (133 loc) · 4.74 KB
/
Copy pathparty.py
File metadata and controls
157 lines (133 loc) · 4.74 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
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
149
150
151
152
153
154
155
156
157
# For copyright and license terms, see COPYRIGHT.rst (top level of repository)
# Repository: https://github.com/C3S/collecting_society
from trytond.model import ModelView, ModelSQL, fields, Unique
from trytond.pool import PoolMeta, Pool
from trytond.transaction import Transaction
from .collecting_society import (
MixinIdentifier,
EntityOrigin,
PublicApi,
ClaimState,
)
__all__ = [
'Party',
'PartyIdentifier',
'PartyIdentifierSpace',
'PartyCategory',
'ContactMechanism',
'Category',
'Address'
]
class Party(EntityOrigin, PublicApi, ClaimState, 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')
firstname = fields.Char('Firstname')
lastname = fields.Char('Lastname')
birthdate = fields.Date('Birth Date')
repertoire_terms_accepted = fields.Boolean(
'Terms of Service Acceptance for Repertoire')
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)
# backlinks
collecting_societies = fields.One2Many(
'collecting_society', 'party', 'Collecting Societies')
labels = fields.One2Many(
'label', 'party', 'Labels')
publishers = fields.One2Many(
'publisher', 'party', 'Publishers')
creation_rights = fields.One2Many(
'creation.right', 'rightsholder', 'Creation Rightsholder')
release_rights = fields.One2Many(
'release.right', 'rightsholder', 'Release Rightsholder')
artists = fields.One2Many('artist', 'party', 'Artists')
default_solo_artist = fields.Many2One(
'artist', 'Default Solo Artist',
help='The default solo artist of this party')
@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_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