mirror of
https://bitbucket.org/presik/trytonpsk-crm_fiduprevisora.git
synced 2023-12-14 05:33:07 +01:00
56 lines
2 KiB
Python
56 lines
2 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 fields, ModelSQL, ModelView
|
||
|
from trytond.pool import PoolMeta, Pool
|
||
|
from trytond.pyson import Eval, If, In, Get, Or, Bool, Not
|
||
|
from trytond.transaction import Transaction
|
||
|
|
||
|
|
||
|
class RegionFiduprevisora(ModelSQL, ModelView):
|
||
|
'Region Fiduprevisora'
|
||
|
__name__ = 'crm.region_fiduprevisora'
|
||
|
_rec_name = 'name'
|
||
|
name = fields.Char('Name', required=True)
|
||
|
departments = fields.Function(fields.One2Many('crm.fiduprevisora_department', None,
|
||
|
'Departments'), 'get_departments')
|
||
|
|
||
|
def get_departments(self, name):
|
||
|
Departments = Pool().get('crm.fiduprevisora_department')
|
||
|
departments = Departments.search([
|
||
|
('region', '=', self.id)
|
||
|
])
|
||
|
if departments:
|
||
|
return [d.id for d in departments]
|
||
|
else:
|
||
|
return []
|
||
|
|
||
|
|
||
|
class DepartmentCode(metaclass=PoolMeta):
|
||
|
__name__ = "party.department_code"
|
||
|
region = fields.Many2One('crm.region_fiduprevisora', 'Region')
|
||
|
emails = fields.One2Many('crm.fiduprevisora_department.email',
|
||
|
'department', 'Emails')
|
||
|
|
||
|
|
||
|
class DepartmentEmail(ModelSQL, ModelView):
|
||
|
'Department - Emails'
|
||
|
__name__ = 'crm.fiduprevisora_department.email'
|
||
|
department = fields.Many2One('party.department_code', 'Department', required=True)
|
||
|
email = fields.Char('Email')
|
||
|
|
||
|
|
||
|
class Party(metaclass=PoolMeta):
|
||
|
__name__ = "party.party"
|
||
|
is_affiliate_user = fields.Boolean('Is Affiliate User')
|
||
|
city_attention = fields.Many2One('party.city_code', 'City Attention', states={
|
||
|
'invisible': (Not(Bool(Eval('is_affiliate_user')))),
|
||
|
})
|
||
|
affiliation_state = fields.Selection([
|
||
|
('', ''),
|
||
|
('retirado', 'Retirado'),
|
||
|
('activo', 'Activo'),
|
||
|
('proteccion_laboral', 'Protección Laboral'),
|
||
|
],'Affiliation State', states={
|
||
|
'invisible': (Not(Bool(Eval('is_affiliate_user')))),
|
||
|
})
|