From f71e6f4671f080a706d657fbee421431c5041dad Mon Sep 17 00:00:00 2001 From: camilogs Date: Tue, 19 Sep 2023 11:47:31 -0500 Subject: [PATCH] feat: Se implementa en las pruebas cierre de tarea pendientes --- __init__.py | 2 +- call.py | 33 +++++++++++++++---- call.xml | 5 +++ .../scenario_sale_opportunity_management.rst | 7 ++++ view/pending_task_tree.xml | 1 + 5 files changed, 40 insertions(+), 8 deletions(-) diff --git a/__init__.py b/__init__.py index bbe78bf..f5066d6 100644 --- a/__init__.py +++ b/__init__.py @@ -15,7 +15,7 @@ def register(): user.User, pending_call.PendingCall, call.Call, - call.Task, + call.PendingTask, department.Department, city.City, prospect.ContactMethod, diff --git a/call.py b/call.py index 3a876db..783d8c9 100644 --- a/call.py +++ b/call.py @@ -1,7 +1,6 @@ from trytond.model import ModelSQL, ModelView, fields +from trytond.pyson import Eval from datetime import date - - from .selections.interest import Interest from .selections.call_types import CallTypes from .selections.call_results import CallResults @@ -49,16 +48,36 @@ class Call(ModelSQL, ModelView): return date.today() -class Task(ModelSQL, ModelView): - 'Tarea pendiente a un seguimiento de prospecto' +class PendingTask(ModelSQL, ModelView): + 'Tarea a realizar a un seguimiento de prospecto' __name__ = "sale.pending_task" description = fields.Text('Description', required=True) - done = fields.Boolean('Done') + state = fields.Selection( + [('pending', 'Pending'), + ('done', 'Done')], + 'State') + prospect_trace = fields.Many2One( 'sale.prospect_trace', 'Prospect trace', required=True, readonly=True) @classmethod - def default_done(cls): - return False + def __setup__(cls): + super(PendingTask, cls).__setup__() + cls._buttons.update({ + 'close_task': { + 'invisible': Eval('state') == 'done' + } + }) + + @classmethod + @ModelView.button + def close_task(cls, tasks): + for task in tasks: + task.state = 'done' + task.save() + + @classmethod + def default_state(cls): + return 'pending' diff --git a/call.xml b/call.xml index 2f1caf1..8e5efc9 100644 --- a/call.xml +++ b/call.xml @@ -105,5 +105,10 @@ this repository contains the full copyright notices and license terms. --> id="menu_pending_tasks" action="act_pending_task_tree" icon="tryton-graph"/> + + close_task + Close task + + diff --git a/tests/scenario_sale_opportunity_management.rst b/tests/scenario_sale_opportunity_management.rst index 4661577..646d3f1 100644 --- a/tests/scenario_sale_opportunity_management.rst +++ b/tests/scenario_sale_opportunity_management.rst @@ -282,6 +282,13 @@ Hacer llamada y programar tarea:: >>> task proteus.Model.get('sale.pending_task')(1) + >>> task.state + 'pending' + + >>> task.click('close_task') + >>> task.state + 'done' + Hacer llamada y cerrar venta (Seguimiento de prospecto):: >>> make_call = Wizard('sale.prospect_trace.make_call', [prospect_trace]) >>> make_call.form.description = 'Closed sale' diff --git a/view/pending_task_tree.xml b/view/pending_task_tree.xml index 84c48ff..a947974 100644 --- a/view/pending_task_tree.xml +++ b/view/pending_task_tree.xml @@ -4,4 +4,5 @@ this repository contains the full copyright notices and license terms. --> +