Files
tryton/product.py
T
2014-12-19 12:14:20 +01:00

37 lines
1.1 KiB
Python

# 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 __future__ import unicode_literals
from trytond.pool import PoolMeta
from trytond.model import ModelSQL, fields
__all__ = ['Template', 'Template_Agent']
__metaclass__ = PoolMeta
class Template:
__name__ = 'product.template'
principals = fields.Many2Many('product.template-commission.agent',
'template', 'agent', 'Commission Principals',
domain=[
('type_', '=', 'principal'),
])
@property
def default_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'),
])