trytondo-sale_opportunity_m.../prospect.py
camilogs 0c78983db7
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
feat: se hacen visibles datos relevantes del contacto en prospect_trace
2023-08-09 14:12:52 -05:00

50 lines
1.5 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 ModelSQL, ModelView, fields
from trytond.pyson import Eval, If
class Prospect(ModelSQL, ModelView):
'Prospecto'
__name__ = 'sale.prospect'
_rec_name = 'name'
name = fields.Char('Name')
contact_methods = fields.One2Many(
'prospect.contact_method',
'prospect', 'Contact methods', required=True)
department = fields.Many2One('sale.department', 'Department')
city = fields.Many2One('sale.city', 'City',
domain=[If(Eval('department'),
('parent', '=', Eval('department')))])
@fields.depends('city', 'department')
def on_change_city(self):
if self.city:
self.department = self.city.parent
class ContactMethod(ModelSQL, ModelView):
'Mecanismo de contacto'
__name__ = 'prospect.contact_method'
_type = [
('phone', 'Phone'),
('mobile', 'Mobile'),
('mail', 'Mail')
]
contact_type = fields.Selection(_type, 'Contact type')
value = fields.Char('Value')
name = fields.Char('Name')
position = fields.Char('Position')
prospect = fields.Many2One('sale.prospect', 'Prospect')
def get_rec_name(self, name):
fields_exist = self.name and self.position and self.value
if fields_exist:
return self.name + ' - ' + self.position + ' [' + self.value + ']'