mirror of
https://github.com/NaN-tic/trytond-commission_manager.git
synced 2023-12-14 04:03:00 +01:00
33 lines
1.1 KiB
Python
33 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 trytond.model import ModelView, ModelSQL, fields
|
|
from trytond.pool import PoolMeta
|
|
from trytond.pyson import Eval
|
|
from trytond.transaction import Transaction
|
|
|
|
__all__ = ['Manager', 'Agent']
|
|
|
|
|
|
class Manager(ModelSQL, ModelView):
|
|
'Commission Manager'
|
|
__name__ = 'commission.manager'
|
|
agent = fields.Many2One('commission.agent', 'Agent', required=True)
|
|
agents = fields.One2Many('commission.agent', 'manager', 'Agents',
|
|
add_remove=[
|
|
('manager', '=', None),
|
|
('id', '!=', Eval('agent')),
|
|
], depends=['agent'])
|
|
company = fields.Many2One('company.company', 'Company', required=True)
|
|
|
|
@staticmethod
|
|
def default_company():
|
|
return Transaction().context.get('company')
|
|
|
|
def get_rec_name(self, name):
|
|
return self.agent.rec_name
|
|
|
|
|
|
class Agent(metaclass=PoolMeta):
|
|
__name__ = 'commission.agent'
|
|
manager = fields.Many2One('commission.manager', 'Manager',
|
|
ondelete='CASCADE')
|