add search_current_risk

This commit is contained in:
Elvis 2023-11-13 20:34:52 -05:00
parent 13bef2dec8
commit ed38bd18f1
5 changed files with 85 additions and 4 deletions

View File

@ -1 +0,0 @@
,presik,presik,05.09.2023 16:57,file:///home/presik/.config/libreoffice/4;

View File

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

View File

@ -257,5 +257,33 @@ this repository contains the full copyright notices and license terms. -->
</record>
<menuitem parent="dash.menu_configuration" sequence="250"
action="act_dash_app_crm_fiduprevisora_form" id="menu_dash_app_crm_fiduprevisora_form"/>
<record model="ir.action.act_window.domain" id="act_customer_service_form_domain_higher">
<field name="name">Higher</field>
<field name="sequence" eval="90"/>
<field name="domain" eval="[
('current_risk', '=', 'Higher'),
('state', '=', 'open'),
]" pyson="1"/>
<field name="act_window" ref="crm.act_customer_service_form"/>
</record>
<record model="ir.action.act_window.domain" id="act_customer_service_form_domain_medium">
<field name="name">Medium</field>
<field name="sequence" eval="90"/>
<field name="domain" eval="[
('state', '=', 'open'),
('current_risk', '=', 'Medium')
]" pyson="1"/>
<field name="act_window" ref="crm.act_customer_service_form"/>
</record>
<record model="ir.action.act_window.domain" id="act_customer_service_form_domain_low">
<field name="name">Low</field>
<field name="sequence" eval="90"/>
<field name="domain" eval="[
('state', '=', 'open'),
('current_risk', '=', 'low')
]" pyson="1"/>
<field name="act_window" ref="crm.act_customer_service_form"/>
</record>
</data>
</tryton>

View File

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

View File

@ -2,15 +2,23 @@
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
this repository contains the full copyright notices and license terms. -->
<data>
<xpath expr="/tree/field[@name='efficacy']"
position="replace">
</xpath>
<xpath expr="/tree/field[@name='number']"
position="after">
<field name="efficacy"/>
</xpath>
<xpath expr="/tree/field[@name='city']"
position="after">
</xpath>
<xpath expr="/tree/field[@name='customer']"
position="after">
<field name="current_risk"/>
</xpath>
<xpath expr="/tree/field[@name='party']"
position="after">
<field name="region"/>
<!-- <field name="region"/> -->
<field name="department_region"/>
<field name="city_region"/>
<field name="health_provider"/>