From 6fb2e1d5379e612aea3a73d64364219368087aa9 Mon Sep 17 00:00:00 2001 From: camilogs Date: Sat, 12 Aug 2023 20:46:19 -0500 Subject: [PATCH] =?UTF-8?q?chore:=20se=20invierte=20comprobaci=C3=B3n=20de?= =?UTF-8?q?=20nulo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- prospect_trace.py | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/prospect_trace.py b/prospect_trace.py index 480a778..351bc1d 100644 --- a/prospect_trace.py +++ b/prospect_trace.py @@ -36,18 +36,20 @@ class ProspectTrace(DeactivableMixin, ModelSQL, ModelView): @fields.depends('calls', 'current_interest') def on_change_calls(self): - if self.calls: - last_call = self.calls[-1] - self.current_interest = last_call.interest + if not self.calls: + return - if len(self.calls) > 1: - last_call.call_type = CallTypes.get_call_types()[1][0] - else: - last_call.call_type = CallTypes.get_call_types()[0][0] + last_call = self.calls[-1] + self.current_interest = last_call.interest - if len(self.pending_calls) >= 1: - self.pending_calls = None - self.state = 'open' + if len(self.calls) > 1: + last_call.call_type = CallTypes.get_call_types()[1][0] + else: + last_call.call_type = CallTypes.get_call_types()[0][0] + + if len(self.pending_calls) >= 1: + self.pending_calls = None + self.state = 'open' @fields.depends('pending_calls', 'state') def on_change_pending_calls(self):