From ed38bd18f196357aba2a3b739f938d6470db9731 Mon Sep 17 00:00:00 2001 From: Elvis Date: Mon, 13 Nov 2023 20:34:52 -0500 Subject: [PATCH] add search_current_risk --- .~lock.fiduprevisora.ods# | 1 - customer_service.py | 31 +++++++++++++++++++++++++++++-- customer_service.xml | 28 ++++++++++++++++++++++++++++ locale/es.po | 19 +++++++++++++++++++ view/customer_service_tree.xml | 10 +++++++++- 5 files changed, 85 insertions(+), 4 deletions(-) delete mode 100644 .~lock.fiduprevisora.ods# diff --git a/.~lock.fiduprevisora.ods# b/.~lock.fiduprevisora.ods# deleted file mode 100644 index 4c2c985..0000000 --- a/.~lock.fiduprevisora.ods# +++ /dev/null @@ -1 +0,0 @@ -,presik,presik,05.09.2023 16:57,file:///home/presik/.config/libreoffice/4; \ No newline at end of file diff --git a/customer_service.py b/customer_service.py index a46259a..305527f 100644 --- a/customer_service.py +++ b/customer_service.py @@ -213,7 +213,8 @@ class CustomerService(metaclass=PoolMeta): nursing_mother = fields.Selection(OPTION_SELECT, 'Nursing Mother', states={'required': False}) older_adult = fields.Selection(OPTION_SELECT, 'Older Adult', states={'required': False}) - current_risk = fields.Function(fields.Char('Current Risk'), 'get_current_risk') + current_risk = fields.Function(fields.Char('Current Risk'), 'get_current_risk', + searcher='search_current_risk') @classmethod def __setup__(cls): @@ -399,7 +400,6 @@ class CustomerService(metaclass=PoolMeta): if self.classification == 'reclamo_riesgo_vital' and self.state == 'open': return 'Higher' if self.classification == 'reclamo_riesgo_priorizado' and self.state == 'open': - print(days_diference, self.party.name) if days_diference.days == 0: return 'Medium' if days_diference.days >= 1: @@ -411,6 +411,33 @@ class CustomerService(metaclass=PoolMeta): return 'Medium' return 'low' + @classmethod + def search_current_risk(cls, name, clause): + # pool = Pool() + # CustomerService = pool.get('crm.customer_service') + # customer_service = CustomerService.__table__() + # query = customer_service.select(customer_service.id) + # datetime.today()-(datecustomer_service.cs_date)) + print(clause[2], 'este es mi clause') + cursor = Transaction().connection.cursor() + if clause[2] == 'Higher': + query = f"""select id from crm_customer_service where (state='open' AND media='supersalud') AND + ((classification='reclamo_riesgo_vital') OR + (DATE_PART('day', CURRENT_DATE - cs_date) > 0 AND classification='reclamo_riesgo_priorizado') OR + (DATE_PART('day', CURRENT_DATE - cs_date) > 1 AND classification='reclamo_riesgo_simple'));""" + elif clause[2] == 'Medium': + query = f"""select id from crm_customer_service where (state='open' AND media='supersalud') AND + ((DATE_PART('day', CURRENT_DATE - cs_date)=0 AND classification='reclamo_riesgo_priorizado') OR + (DATE_PART('day', CURRENT_DATE - cs_date)=1 AND classification='reclamo_riesgo_simple'));""" + elif clause[2] == 'low': + query = f"""select id from crm_customer_service where (state='open' AND media='supersalud') AND + ((DATE_PART('day', CURRENT_DATE - cs_date)=0 AND classification='reclamo_riesgo_simple'));""" + cursor.execute(query) + result = cursor.fetchall() + ids = [tupla[0] for tupla in result] + return [('id', 'in', ids)] + # return [('id', 'in', query)] + def send_email_customer(self, template, attachments=[]): if self.department_region and self.department_region.emails: dmt_email = self.department_region.emails[0].email diff --git a/customer_service.xml b/customer_service.xml index d799792..b8ef901 100644 --- a/customer_service.xml +++ b/customer_service.xml @@ -257,5 +257,33 @@ this repository contains the full copyright notices and license terms. --> + + + Higher + + + + + + Medium + + + + + + Low + + + + diff --git a/locale/es.po b/locale/es.po index 6410a44..e42a0b6 100644 --- a/locale/es.po +++ b/locale/es.po @@ -82,6 +82,10 @@ msgctxt "field:crm.customer_service,classification:" msgid "Classification" msgstr "Clasificación" +msgctxt "field:crm.customer_service,current_risk:" +msgid "Current Risk" +msgstr "" + msgctxt "field:crm.customer_service,department_region:" msgid "Department" msgstr "Departamento de Región" @@ -406,6 +410,21 @@ msgctxt "model:ir.action,name:fiduprevisora_report_wizard" msgid "Fiduprevisora Report" msgstr "Reporte Fiduprevisora" +msgctxt "" +"model:ir.action.act_window.domain,name:act_customer_service_form_domain_higher" +msgid "Higher" +msgstr "" + +msgctxt "" +"model:ir.action.act_window.domain,name:act_customer_service_form_domain_low" +msgid "Low" +msgstr "" + +msgctxt "" +"model:ir.action.act_window.domain,name:act_customer_service_form_domain_medium" +msgid "Medium" +msgstr "" + msgctxt "model:ir.ui.menu,name:" msgid "Cities" msgstr "Ciudades" diff --git a/view/customer_service_tree.xml b/view/customer_service_tree.xml index bc54921..71ec4d7 100644 --- a/view/customer_service_tree.xml +++ b/view/customer_service_tree.xml @@ -2,15 +2,23 @@ + + + + + + - +