2017-06-07 13:13:17 +02:00
|
|
|
# The COPYRIGHT file at the top level of this repository contains the full
|
|
|
|
# copyright notices and license terms.
|
2017-12-14 14:40:37 +01:00
|
|
|
from trytond.model import fields
|
2017-06-07 13:13:17 +02:00
|
|
|
from trytond.pool import PoolMeta
|
2017-06-20 13:48:02 +02:00
|
|
|
from . import party
|
2017-06-07 13:13:17 +02:00
|
|
|
|
2017-12-14 11:22:26 +01:00
|
|
|
__all__ = ['Manager', 'Agent']
|
|
|
|
|
|
|
|
|
2017-12-14 14:40:37 +01:00
|
|
|
class Manager:
|
2017-12-14 11:22:26 +01:00
|
|
|
__metaclass__ = PoolMeta
|
|
|
|
__name__ = 'commission.manager'
|
2017-12-14 14:40:37 +01:00
|
|
|
companies = fields.Function(fields.One2Many('company.company', None,
|
|
|
|
'Companies'), 'get_companies', searcher='search_companies')
|
|
|
|
|
|
|
|
def get_companies(self, name):
|
|
|
|
if self.agent:
|
|
|
|
return [c.id for c in self.agent.party.companies]
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def search_companies(cls, name, clause):
|
|
|
|
return [('agent.party.companies',) + tuple(clause[1:])]
|
2017-06-07 13:13:17 +02:00
|
|
|
|
|
|
|
|
2018-05-11 01:12:18 +02:00
|
|
|
class Agent(party.PartyCompanyMixin):
|
2017-06-07 13:13:17 +02:00
|
|
|
__metaclass__ = PoolMeta
|
2017-06-20 16:31:22 +02:00
|
|
|
__name__ = 'commission.agent'
|