feat: Se agrega dominio de ciudad y departamento en creación de prospecto

This commit is contained in:
Camilo Gonzalez 2023-08-06 14:27:52 -05:00
parent beb285485d
commit 6ecb0da346
3 changed files with 20 additions and 2 deletions

View File

@ -26,7 +26,7 @@ class Call(ModelSQL, ModelView):
def default_date(cls):
return date.today()
@fields.depends('interest')
@fields.depends('interest', 'call_result')
def on_change_interest(self):
if self.interest:
if self.interest == '0':

View File

@ -1,6 +1,7 @@
# 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):
@ -13,7 +14,14 @@ class Prospect(ModelSQL, ModelView):
'prospect.contact_method', 'prospect', 'Contact methods')
department = fields.Many2One('sale.department', 'Department')
city = fields.Many2One('sale.city', 'City')
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):

View File

@ -47,6 +47,11 @@ Crear prospecto::
>>> prospect.name = 'guchito S.A.S'
>>> contact_method = prospect.contact_methods.new(contact_type = 'mobile', value = '31223425234')
>>> contact_method = prospect.contact_methods.new(contact_type = 'mail', value = 'peralto@guchitos.org')
.. >>> Department = Model.get('sale.department')
.. >>> cundinamarca, = Department.find([('code', '=', 'CO-25')])
.. >>> prospect.department = cundinamarca
>>> City = Model.get('sale.city')
>>> medellin, = City.find([('code', '=', 'CO-05001')])
>>> prospect.city = medellin
@ -57,6 +62,11 @@ Verificar estado final de creación de prospecto::
[proteus.Model.get('prospect.contact_method')(1), proteus.Model.get('prospect.contact_method')(2)]
>>> prospect.city.parent.code
'CO-05'
>>> prospect.department.code
'CO-05'
------------------------------------
Asignación de prospectos a operarios