diff --git a/call.py b/call.py index c7d4f8e..59234f3 100644 --- a/call.py +++ b/call.py @@ -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': diff --git a/prospect.py b/prospect.py index a3e5615..04d3146 100644 --- a/prospect.py +++ b/prospect.py @@ -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): diff --git a/tests/scenario_sale_opportunity_management.rst b/tests/scenario_sale_opportunity_management.rst index cfa449b..cd0a8d2 100644 --- a/tests/scenario_sale_opportunity_management.rst +++ b/tests/scenario_sale_opportunity_management.rst @@ -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