-
Notifications
You must be signed in to change notification settings - Fork 4
/
product.py
40 lines (31 loc) · 1.19 KB
/
product.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
# 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 ModelSQL, fields
from trytond.pool import PoolMeta
class Template(metaclass=PoolMeta):
__name__ = 'product.template'
principals = fields.Many2Many('product.template-commission.agent',
'template', 'agent', 'Commission Principals',
domain=[
('type_', '=', 'principal'),
],
help="The principals who pay a commission when the product is sold.")
@property
def principal(self):
if self.principals:
return self.principals[0]
class Template_Agent(ModelSQL):
'Product Template - Commission Agent'
__name__ = 'product.template-commission.agent'
template = fields.Many2One('product.template', 'Template',
required=True, select=True)
agent = fields.Many2One('commission.agent', 'Agent',
required=True, select=True,
domain=[
('type_', '=', 'principal'),
])
class Product(metaclass=PoolMeta):
__name__ = 'product.product'
@property
def principal(self):
return self.template.principal