diff --git a/Util/interest.py b/Util/interest.py new file mode 100644 index 0000000..dc42c8f --- /dev/null +++ b/Util/interest.py @@ -0,0 +1,11 @@ +class Interest(): + @staticmethod + def get_interest_levels(): + interest_levels = [ + ('0', '0 - No contestó'), + ('1', '1 - total desinterés'), + ('2', '2 - Interés intermedio'), + ('3', '3 - Interés alto, generar venta') + ] + + return interest_levels \ No newline at end of file diff --git a/call.py b/call.py index 0a5a984..83e02ae 100644 --- a/call.py +++ b/call.py @@ -1,5 +1,6 @@ from trytond.model import ModelSQL, ModelView, fields from datetime import date +from Util.interest import Interest class Call(ModelSQL, ModelView): 'Llamada' @@ -11,15 +12,7 @@ class Call(ModelSQL, ModelView): prospect_trace = fields.Many2One('sale.prospect_trace', 'Prospect track') - interest_types = [ - ('0', '0 - No contestó'), - ('1', '1 - total desinterés'), - ('2', '2 - Interés intermedio'), - ('3', '3 - Interés alto, generar venta') - ] - - interest = fields.Selection(interest_types, 'Interest') - + interest = fields.Selection(Interest.get_interest_levels(), 'Interest') @classmethod def default_date(cls): diff --git a/prospect_trace.py b/prospect_trace.py index f0a91f5..fa8d2b0 100644 --- a/prospect_trace.py +++ b/prospect_trace.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 Util.interest import Interest class ProspectTrace(ModelSQL, ModelView): 'Seguimiento de un prospecto' @@ -14,14 +15,8 @@ class ProspectTrace(ModelSQL, ModelView): calls = fields.One2Many('sale.call', 'prospect_trace', "Calls") - interest_types = [ - ('0', '0 - No contestó'), - ('1', '1 - total desinterés'), - ('2', '2 - Interés intermedio'), - ('3', '3 - Interés alto, generar venta') - ] - - current_interest = fields.Function(fields.Selection(interest_types, 'Interest'), '_get_current_interest') + _interest_field_type = fields.Selection(Interest.get_interest_levels(), 'Interest') + current_interest = fields.Function(_interest_field_type, '_get_current_interest') @fields.depends('prospect') def on_change_prospect(self):