From d158d1c72886a7975b5756beb2846aea7fa5f64a Mon Sep 17 00:00:00 2001 From: oscar alvarez Date: Fri, 17 Feb 2023 13:34:43 -0500 Subject: [PATCH] Fix --- COPYRIGHT | 2 +- __init__.py | 14 +++---- case.py | 4 +- configuration.py | 10 +++-- customer_service.py | 93 +++++++++++++++++++++++---------------------- dash.py | 9 +++++ dash.xml | 19 +++++++++ exceptions.py | 1 - party.py | 30 +++++++-------- tryton.cfg | 3 +- 10 files changed, 108 insertions(+), 77 deletions(-) create mode 100644 dash.xml diff --git a/COPYRIGHT b/COPYRIGHT index 97100e6..859a621 100644 --- a/COPYRIGHT +++ b/COPYRIGHT @@ -1,4 +1,4 @@ -Copyright (C) 2019 Presik Technologies. +Copyright (C) 2019-2023 Presik Technologies. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/__init__.py b/__init__.py index c92b2f0..796dddf 100644 --- a/__init__.py +++ b/__init__.py @@ -1,6 +1,5 @@ -#This file is part product_barcode module for Tryton. -#The COPYRIGHT file at the top level of this repository contains -#the full copyright notices and license terms. +# 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.pool import Pool from . import configuration @@ -17,10 +16,6 @@ def register(): party.RegionFiduprevisora, party.DepartmentCode, party.Party, - # customer_service.UserFiduprevisora, - # customer_service.FiduprevisoraDepartment, - # customer_service.FiduprevisoraCity, - # customer_service.FiduprevisoraRegionDepartment, customer_service.ListSpecialty, customer_service.ReceiverService, customer_service.CustomerService, @@ -32,6 +27,11 @@ def register(): customer_service.CustomerReceiver, customer_service.AppCustomerFiduprevisora, dash.DashApp, + dash.AppConsultaPQR, + # customer_service.UserFiduprevisora, + # customer_service.FiduprevisoraDepartment, + # customer_service.FiduprevisoraCity, + # customer_service.FiduprevisoraRegionDepartment, module='crm_fiduprevisora', type_='model') Pool.register( customer_service.FiduprevisoraReportWizard, diff --git a/case.py b/case.py index b7e82d4..e2aedaf 100644 --- a/case.py +++ b/case.py @@ -1,7 +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 ModelView, ModelSQL, fields -from trytond.pool import Pool, PoolMeta +from trytond.model import fields +from trytond.pool import PoolMeta from trytond.pyson import Eval, Bool, Not diff --git a/configuration.py b/configuration.py index 08f76a0..6104314 100644 --- a/configuration.py +++ b/configuration.py @@ -6,7 +6,9 @@ from trytond.pool import PoolMeta class Configuration(metaclass=PoolMeta): __name__ = 'crm.configuration' - - region_defect = fields.Many2One('crm.region_fiduprevisora', 'Region For Defect') - response_mail_template = fields.Many2One('email.template', 'Template Response Emails') - notification_mail_template = fields.Many2One('email.template', 'Template Notification Emails') + region_defect = fields.Many2One('crm.region_fiduprevisora', + 'Region For Defect') + response_mail_template = fields.Many2One('email.template', + 'Template Response Emails') + notification_mail_template = fields.Many2One('email.template', + 'Template Notification Emails') diff --git a/customer_service.py b/customer_service.py index aa1285e..35281b3 100644 --- a/customer_service.py +++ b/customer_service.py @@ -1,14 +1,11 @@ # 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 __future__ import with_statement -from bdb import effective - from datetime import datetime, timedelta, time from trytond.model import Workflow, ModelView, ModelSQL, fields -from trytond.pyson import Eval, If, In, Get, Or, Bool, Not +from trytond.pyson import Eval, Or, Bool, Not from trytond.transaction import Transaction from trytond.pool import Pool, PoolMeta -from trytond.wizard import Wizard, StateView, Button, StateReport, StateTransition +from trytond.wizard import Wizard, StateView, Button, StateReport from trytond.report import Report from .exceptions import MessageUserError from trytond.modules.dash.dash import DashAppBase @@ -18,16 +15,16 @@ STATES = { } NEW_MEDIA = new_sel = [ - ('', ''), - ('sede', 'Sede'), - ('web', 'Web'), - ('supersalud', 'Supersalud'), + ('', ''), + ('sede', 'Sede'), + ('web', 'Web'), + ('supersalud', 'Supersalud'), ] CLASSIFICATION = new_sel = [ - ('', ''), - ('riesgo_vida', 'Riesgo de Vida'), - ('regular', 'Regular'), + ('', ''), + ('riesgo_vida', 'Riesgo de Vida'), + ('regular', 'Regular'), ] SEXUAL_DIVERSITY = [ @@ -63,9 +60,7 @@ class ReceiverService(ModelSQL, ModelView): __name__ = 'crm.receiver_service' _rec_name = 'name' name = fields.Char('Name', required=True) - # email = fields.Char('Email', required=True) - emails = fields.One2Many('crm.receiver_service.email', - 'receiver', 'Emails') + emails = fields.One2Many('crm.receiver_service.email', 'receiver', 'Emails') def get_rec_name(self, name): return self.name @@ -76,22 +71,23 @@ class ReceiverService(ModelSQL, ModelView): bool_op = 'AND' else: bool_op = 'OR' - return [bool_op, - ('name',) + tuple(clause[1:]), - ] + return [ + bool_op, + ('name',) + tuple(clause[1:]), + ] class ReceiverEmail(ModelSQL, ModelView): 'Receiver - Emails' __name__ = 'crm.receiver_service.email' - receiver = fields.Many2One('crm.receiver_service', 'Receiver', required=True) + receiver = fields.Many2One('crm.receiver_service', 'Receiver', + required=True) email = fields.Char('Email') class ListSpecialty(ModelSQL, ModelView): 'List Specialty' __name__ = 'list.specialty' - name = fields.Char('Name', required=True) code = fields.Char('Code', required=True) @@ -107,7 +103,7 @@ class HealthProvider(ModelSQL, ModelView): name = fields.Function(fields.Char('Name'), 'get_rec_name') party = fields.Many2One('party.party', 'Party') city = fields.Many2One('party.city_code', 'City') - asset = fields.Boolean('Asset', help="¡Check this if the provider is active!") + asset = fields.Boolean('Asset', help="Check this if the provider is active!") def get_rec_name(self, name): return self.party.name @@ -151,25 +147,26 @@ class CustomerService(metaclass=PoolMeta): attach_customer_1 = fields.Char('Attach Customer Web...', readonly=True) attach_customer_2 = fields.Char('Attach Customer Web...', readonly=True) attachments = fields.One2Many('crm.fiduprevisora.attachments', - 'service', 'Attachments') + 'service', 'Attachments') others_receivers = fields.One2Many('crm.customer_receiver', - 'customer_service', 'Receivers') + 'customer_service', 'Receivers') others_receivers_string = fields.Function(fields.Char('Others Receicers'), - 'get_others_receivers_string') + 'get_others_receivers_string') classification = fields.Selection(CLASSIFICATION, 'Classification', states={ 'required': (Eval('media') == 'supersalud'), 'invisible': (Eval('media') != 'supersalud'), }) - detailed_especific_1= fields.Many2One('list.specialty', 'Detailed Especific 1', - states={'required': True}) + detailed_especific_1= fields.Many2One('list.specialty', + 'Detailed Especific 1', states={'required': True}) detailed_especific_2= fields.Many2One('list.specialty', 'Detailed Especific 2') detailed_especific_3= fields.Many2One('list.specialty', 'Detailed Especific 3') ethnical_group = fields.Selection(ETHNICAL_GROUP, 'Ethnical Group', states={'required': False}) sexual_diversity = fields.Selection(SEXUAL_DIVERSITY, 'Sexual Diversity', states={'required': False}) - displaced = fields.Selection(OPTION_SELECT, 'Displaced', states={'required': False}) + displaced = fields.Selection(OPTION_SELECT, 'Displaced', + states={'required': False}) victim_of_violence = fields.Selection(OPTION_SELECT, 'Victim Of Violence', states={'required': False}) disabled_person = fields.Selection(OPTION_SELECT, 'Disabled Person', @@ -211,7 +208,8 @@ class CustomerService(metaclass=PoolMeta): config = Pool().get('crm.configuration')(1) template = config.response_mail_template if not template: - service.get_message('No se ha definido una plantilla para el envío del correo.') + service.get_message( + 'No se ha definido una plantilla para el envío del correo.') _attachments = [] if service.attachments: for att in service.attachments: @@ -364,9 +362,11 @@ class CustomerService(metaclass=PoolMeta): template.from_email = dmt_email template.subject = template.subject + self.company.party.name if attachments: - response = self._send_mails(template, self, self.email or self.party.email, True, attachments) + response = self._send_mails( + template, self, self.email or self.party.email, True, attachments) else: - response = self._send_mails(template, self, self.email or self.party.email, False, []) + response = self._send_mails( + template, self, self.email or self.party.email, False, []) if response.status_code == 202: self.write([self], {'sended_mail': True}) else: @@ -378,12 +378,11 @@ class CustomerService(metaclass=PoolMeta): config = pool.get('crm.configuration')(1) template = config.notification_mail_template if template: - attach_dict = {} + # attach_dict = {} template.subject = template.subject + self.company.party.name response = Template.send(template, self, email, attach=False, attachments=[]) if not response or response.status_code != 202: - print(email) self.write({self}, {'notes': 'Fallo envio al correo: ' + email}) def send_emails_department(self): @@ -394,7 +393,7 @@ class CustomerService(metaclass=PoolMeta): def send_emails_receivers(self, template, attachments=[]): attach = False if attachments: - attach= True + attach = True template.subject = template.subject + self.company.party.name if self.department_region and self.department_region.emails: dmt_email = self.department_region.emails[0].email @@ -427,18 +426,16 @@ class CustomerService(metaclass=PoolMeta): today = Date.today() date_ = today - timedelta(days=30) dt = datetime.combine(date_, datetime.min.time()) - # company = Transaction().context.get('company') res = { 'status': 'success', 'msg': 'Requerimiento enviado satifactoriamente !!', - } - print(args, 'this is args teh..........', dt) + } services = cls.search([ ('party', '=', args['party']), ('cs_date', '>=', dt), ('state', '=', 'open'), ('case', '=', args['case']), - ]) + ]) services = None special_population = args.pop('special_population') if args.get('special_population') else [] fields_ = [ @@ -489,11 +486,12 @@ class FiduprevisoraReportStart(ModelView): party = fields.Many2One('party.party', 'Party') region = fields.Many2One('crm.region_fiduprevisora', 'Region') receiver_service = fields.Many2One('crm.receiver_service', 'Receiver') - department_region = fields.Many2One('party.department_code', 'Department', domain=[ - ('region', '=', Eval('region')) + department_region = fields.Many2One('party.department_code', 'Department', + domain=[ + ('region', '=', Eval('region')) ]) city_region = fields.Many2One('party.city_code', 'City', domain=[ - ('department', '=', Eval('department_region')) + ('department', '=', Eval('department_region')) ]) @staticmethod @@ -516,11 +514,12 @@ class FiduprevisoraReportStart(ModelView): class FiduprevisoraReportWizard(Wizard): 'Fiduprevisora Report Wizard' __name__ = 'crm_fiduprevisora.fiduprevisora_report.wizard' - start = StateView('crm_fiduprevisora.fiduprevisora_report.start', + start = StateView( + 'crm_fiduprevisora.fiduprevisora_report.start', 'crm_fiduprevisora.fiduprevisora_report_start_view_form', [ Button('Cancel', 'end', 'tryton-cancel'), Button('Print', 'print_', 'tryton-ok', default=True), - ]) + ]) print_ = StateReport('crm_fiduprevisora.fiduprevisora_report') def do_print_(self, action): @@ -603,7 +602,6 @@ class FiduprevisoraReport(Report): ('city_region', '=', city_region), ) services = Service.search(dom_service) - report_context['records'] = services report_context['start_date'] = start_date report_context['end_date'] = end_date @@ -614,10 +612,13 @@ class FiduprevisoraReport(Report): class CustomerReceiver(ModelSQL, ModelView): 'Customer Receiver' __name__ = 'crm.customer_receiver' - customer_service = fields.Many2One('crm.customer_service', 'Customer Service', required=True) - receiver = fields.Many2One('crm.receiver_service', 'Receiver', required=True) + customer_service = fields.Many2One('crm.customer_service', + 'Customer Service', required=True) + receiver = fields.Many2One('crm.receiver_service', 'Receiver', + required=True) media = fields.Selection(NEW_MEDIA, 'Media', required=True) + class AppCustomerFiduprevisora(DashAppBase): 'App Customer Fiduprevisora' - __name__ = 'dash.app.crm_fiduprevisora' \ No newline at end of file + __name__ = 'dash.app.crm_fiduprevisora' diff --git a/dash.py b/dash.py index 2af363e..cb325dd 100644 --- a/dash.py +++ b/dash.py @@ -1,6 +1,8 @@ # 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.pool import PoolMeta +from trytond.modules.dash.dash import DashAppBase class DashApp(metaclass=PoolMeta): @@ -11,6 +13,7 @@ class DashApp(metaclass=PoolMeta): origins = super(DashApp, cls)._get_origin() origins.extend([ 'dash.app.crm_fiduprevisora', + 'dash.app.consulta_pqr' ]) return origins @@ -19,5 +22,11 @@ class DashApp(metaclass=PoolMeta): options = super(DashApp, cls).get_selection() options.extend([ ('crm_fiduprevisora', 'Crm Fiduprevisora'), + ('consulta_pqr', 'Cosulta PQR'), ]) return options + + +class AppConsultaPQR(DashAppBase): + "App Consulta PQR" + __name__ = "dash.app.consulta_pqr" diff --git a/dash.xml b/dash.xml new file mode 100644 index 0000000..a509fa1 --- /dev/null +++ b/dash.xml @@ -0,0 +1,19 @@ + + + + + + + 1 + + external + + + Consulta PQRs + True + consulta_pqr + + + + diff --git a/exceptions.py b/exceptions.py index fe6187e..e76994a 100644 --- a/exceptions.py +++ b/exceptions.py @@ -1,7 +1,6 @@ # 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.exceptions import UserError -from trytond.model.exceptions import ValidationError class MessageUserError(UserError): diff --git a/party.py b/party.py index 9682a51..5a9ab75 100644 --- a/party.py +++ b/party.py @@ -2,16 +2,14 @@ # this repository contains the full copyright notices and license terms. from trytond.model import fields, ModelSQL, ModelView from trytond.pool import PoolMeta, Pool -from trytond.pyson import Eval, If, In, Get, Or, Bool, Not -from trytond.transaction import Transaction -from operator import getitem, delitem, setitem +from trytond.pyson import Eval, Bool, Not AFILIATION_STATE = [ - ('', ''), - ('retirado', 'Retirado'), - ('activo', 'Activo'), - ('proteccion_laboral', 'Protección Laboral'), - ] + ('', ''), + ('retirado', 'Retirado'), + ('activo', 'Activo'), + ('proteccion_laboral', 'Protección Laboral'), +] TYPE_DOCUMENT = { @@ -47,7 +45,7 @@ class DepartmentCode(metaclass=PoolMeta): __name__ = "party.department_code" region = fields.Many2One('crm.region_fiduprevisora', 'Region') emails = fields.One2Many('crm.fiduprevisora_department.email', - 'department', 'Emails') + 'department', 'Emails') class DepartmentEmail(ModelSQL, ModelView): @@ -60,12 +58,14 @@ class DepartmentEmail(ModelSQL, ModelView): class Party(metaclass=PoolMeta): __name__ = "party.party" is_affiliate_user = fields.Boolean('Is Affiliate User') - city_attention = fields.Many2One('party.city_code', 'City Attention', states={ - 'invisible': (Not(Bool(Eval('is_affiliate_user')))), - }) - affiliation_state = fields.Selection(AFILIATION_STATE ,'Affiliation State', states={ - 'invisible': (Not(Bool(Eval('is_affiliate_user')))), - }) + city_attention = fields.Many2One('party.city_code', 'City Attention', + states={ + 'invisible': (Not(Bool(Eval('is_affiliate_user')))), + }) + affiliation_state = fields.Selection(AFILIATION_STATE , + 'Affiliation State', states={ + 'invisible': (Not(Bool(Eval('is_affiliate_user')))), + }) @classmethod def __setup__(cls): diff --git a/tryton.cfg b/tryton.cfg index 220f6ab..5460b75 100644 --- a/tryton.cfg +++ b/tryton.cfg @@ -1,5 +1,5 @@ [tryton] -version=6.0.1 +version=6.0.2 depends: crm email @@ -11,3 +11,4 @@ xml: customer_service.xml configuration.xml message.xml + dash.xml