chore: Se elimina código duplicado extrayendo niveles de interés en una clase aparte
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

This commit is contained in:
Camilo Gonzalez 2023-08-03 18:18:13 +00:00
parent 41036b1c59
commit a79490ed0f
3 changed files with 16 additions and 17 deletions

11
Util/interest.py Normal file
View File

@ -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

11
call.py
View File

@ -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):

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 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):