Commit bece1c86 by juan

Base codigo nuevo

1 parent bd9dfc9d
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from . import models from . import models
from . import controllers from . import controllers
from . import wizard
\ No newline at end of file \ No newline at end of file
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
'data': [ 'data': [
'security/permisos.xml', 'security/permisos.xml',
'security/ir.model.access.csv', 'security/ir.model.access.csv',
'wizard/generarmensaje.xml',
'views/incidencia_view.xml', 'views/incidencia_view.xml',
'views/mensaje_view.xml', 'views/mensaje_view.xml',
'views/menu.xml', 'views/menu.xml',
......
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from . import controllers
from . import controller_mensaje
\ No newline at end of file \ No newline at end of file
#from . import controllers
#from . import controller_mensaje
\ No newline at end of file \ No newline at end of file
...@@ -7,7 +7,7 @@ TOKEN ="""34567uykjhgfd4567iukhjgfe43567ujhgfder456yhgfde""" ...@@ -7,7 +7,7 @@ TOKEN ="""34567uykjhgfd4567iukhjgfe43567ujhgfder456yhgfde"""
class controlador_soporte_mensajes(http.Controller): class controlador_soporte_mensajes(http.Controller):
"""Controlador orientado al envio de mensajes entre incidencias y soporte""" """Controlador orientado al envio de mensajes entre incidencias y soporte"""
@http.route('/soporteMensaje', auth='public', type='json' , website=False ,csrf=False, methods = ['POST','GET']) @http.route('/soporteIncidencias/soporteMensaje', auth='public', type='json' , website=False ,csrf=False, methods = ['POST','GET'])
def index(self, **kw): def index(self, **kw):
if not kw["token"] == TOKEN: if not kw["token"] == TOKEN:
return({"resultado":"ALERTA DE SEGURIDAD error autenticacion"}) return({"resultado":"ALERTA DE SEGURIDAD error autenticacion"})
......
...@@ -3,9 +3,14 @@ from odoo.exceptions import UserError ...@@ -3,9 +3,14 @@ from odoo.exceptions import UserError
from odoo import models, fields, api from odoo import models, fields, api
import datetime import datetime
from datetime import datetime from datetime import datetime
import requests, json import requests, json, random
headers = {'Content-Type': 'application/json'} headers = {'Content-Type': 'application/json'}
TokensValidos = [
"dadsaf.tghrth,tre433325456,34fgevdsñQWEERFcwqe445VSDasfGrew4vsdfgljk456gf4we8wfg4g4e8r4",
"retbgv,opervbtolsdfhgtr,wfrrwegf,te,hthrjyqwwqefwer57e74fwtgreñloewwefcd,{sdafsdasdffw6",
"asdASFefcECWÑlfweñ324dcfwcfdwefcñfdwqecwedfñfc43fd.dfqwe,dfweqf3cvbtr.LDSFsdfsaewfvresf",
]
class hgt_soporte_incidencia(models.Model): class hgt_soporte_incidencia(models.Model):
_name = 'hgt.soporte_incidencia' _name = 'hgt.soporte_incidencia'
...@@ -32,11 +37,13 @@ class hgt_soporte_incidencia(models.Model): ...@@ -32,11 +37,13 @@ class hgt_soporte_incidencia(models.Model):
) )
si_name = fields.Char( si_name = fields.Char(
string=u'Nombre', string=u'Codigo Insidencia',
readonly=True
) )
si_descripcion = fields.Text( si_descripcion = fields.Text(
string=u'Descripción', string=u'Descripción',
required=True
) )
si_estado = fields.Char( si_estado = fields.Char(
...@@ -71,25 +78,17 @@ class hgt_soporte_incidencia(models.Model): ...@@ -71,25 +78,17 @@ class hgt_soporte_incidencia(models.Model):
default=False default=False
) )
def enviarMensaje(self): estado = fields.Selection(string='Estado', selection=[
if (self.subida == False): ('borrador', 'Borrador'),
raise UserError("Debe hacer click en Subir Incidencia antes de enviar su mensaje") ('abierta', 'Abierta'),
else: ('proceso', 'En Proceso'),
if (self.si_texto_mensaje == False) or (self.si_texto_mensaje == ""): ('cerrada', 'Cerrada'),
raise UserError("No se puede enviar un mensaje vacío") ],
datos = {'si_mensaje': self.si_texto_mensaje, required=True,
'si_interno': False, default="borrador",
} readonly=True)
nvo_mensaje = self.env['hgt.soporte_mensaje'].create(datos)
lista_msj = []
for msj in self.si_mensajes:
lista_msj.append(msj.id)
lista_msj.append(nvo_mensaje.id)
self.si_mensajes = lista_msj
self.si_texto_mensaje = False
self.registrar_mensaje(nvo_mensaje)
if (self.si_si_interno == False):
self.enviar_mensaje(nvo_mensaje)
def registrar_mensaje(self, mens): def registrar_mensaje(self, mens):
text = mens.si_mensaje text = mens.si_mensaje
...@@ -159,11 +158,32 @@ class hgt_soporte_incidencia(models.Model): ...@@ -159,11 +158,32 @@ class hgt_soporte_incidencia(models.Model):
#print(frespuesta) #print(frespuesta)
def GenerarToken(self):
return(random.choice(TokensValidos))
def ChequearToken(self,token):
return(token in TokensValidos)
@api.model
def create(self, values):
rta = super(hgt_soporte_incidencia, self).create(values)
empresa = self.env['res.company']._company_default_get()
rta.si_name = f"{empresa.display_name} {str(rta.id).zfill(5)}"
return(rta)
def AgregarMensaje(self):
msj = self.env['soporte.mensaje_wiz'].create({"incidencia":self.id})
return {
'name': "Mensaje",
'type': 'ir.actions.act_window',
'res_model': 'soporte.mensaje_wiz',
'view_mode': 'form',
'view_type': 'form',
'res_id': msj.id,
'target': 'new',
}
#print(hgt_soporte_incidencia.GenerarToken())
# si_url = fields.Char(string='Url de ticketera') # si_url = fields.Char(string='Url de ticketera')
# _sql_constraints = [('id_ost_uniq', 'unique (id_ost)', 'Id Ticket must be unique.')] # _sql_constraints = [('id_ost_uniq', 'unique (id_ost)', 'Id Ticket must be unique.')]
......
Se separa la logica de cliente servidor
hgt_soporte es el soporte de clientes
hgt_hgtsop tendra la logica de servidor central
El cliente informara al server via cliente
El server se conecta al cliente via hgt_dispositivos
De esta forma mejoramos la seguridad entre server y aislamos problemas de conexion
En el modelo incidencias se genera un metodo GenerarToken Que tendra el listado validos
de token en los sistemas, seguridad basica.
\ No newline at end of file \ No newline at end of file
...@@ -32,8 +32,10 @@ ...@@ -32,8 +32,10 @@
<tree> <tree>
<field name="si_name" nolabel="1"/> <field name="si_name" nolabel="1"/>
<!-- <field name="si_ost_asunto" /> --> <!-- <field name="si_ost_asunto" /> -->
<field name="si_descripcion"/>
<field name="estado"/>
<field name="si_fecha"/> <field name="si_fecha"/>
<field name="si_cerrada" /> <!--<field name="si_cerrada" />-->
<!-- <field name="si_url" widget="url"/> --> <!-- <field name="si_url" widget="url"/> -->
<!-- <field name="si_descripcion"/> --> <!-- <field name="si_descripcion"/> -->
</tree> </tree>
...@@ -54,12 +56,12 @@ ...@@ -54,12 +56,12 @@
<button type="object" name="enviarIncidencia" string="Subir Incidencia" attrs="{ 'invisible' :[('subida','=', True)] }" class="oe_highlight"/> <button type="object" name="enviarIncidencia" string="Subir Incidencia" attrs="{ 'invisible' :[('subida','=', True)] }" class="oe_highlight"/>
<field name="si_cerrada" invisible="1" /> <field name="si_cerrada" invisible="1" />
</header> </header>
<group col="4" string="Incidencia"> <group col="2" string="Incidencia">
<field name="si_name" colspan="2" attrs="{'readonly':[('si_cerrada','=',True)]}"/> <field name="si_name" colspan="2"/>
<!-- <field colspan="2" name="si_numero" readonly="1" /> --> <!-- <field colspan="2" name="si_numero" readonly="1" /> -->
<field colspan="2" name="si_fecha" attrs="{'readonly':[('si_cerrada','=',True)]}"/> <field colspan="2" name="si_fecha" readonly="1"/>
<field colspan="2" name="si_descripcion" attrs="{'readonly':[('si_cerrada','=',True)]}"/> <field colspan="2" name="si_descripcion" attrs="{'readonly':[('si_cerrada','=',True)]}"/>
<field colspan="2" name="si_estado" readonly="1" /> <field colspan="2" name="estado" readonly="1" />
<field colspan="2" name="si_responsabilidad" readonly="1"/> <field colspan="2" name="si_responsabilidad" readonly="1"/>
<field colspan="2" name="subida" invisible="1"/> <field colspan="2" name="subida" invisible="1"/>
</group> </group>
...@@ -69,16 +71,16 @@ ...@@ -69,16 +71,16 @@
<field name="si_historico_mensajes" readonly="1" colspan="2" nolabel='1'/> <field name="si_historico_mensajes" readonly="1" colspan="2" nolabel='1'/>
</group> </group>
<group col="2"> <group col="2">
<field name="si_texto_mensaje" nolabel='1' attrs="{'readonly':[('si_cerrada','=',True)]}"/>
<button name="enviarMensaje" attrs="{'readonly':[('si_cerrada','=',True)]}" class="oe_edit_only" string="Enviar Mensaje" type="object" /> <button name="AgregarMensaje" string="Agregar Mensaje" type="object" />
<field name="si_si_interno" attrs="{'readonly':[('si_cerrada','=',True)]}" colspan="1"/>
</group> </group>
<group> <group>
<field name="si_mensajes" required="0" nolabel="1" > <field name="si_mensajes" required="0" nolabel="1" >
<tree delete="false" create="false"> <tree delete="false" create="false">
<field name="si_mens_fecha" attrs="{'readonly': True}" />
<field name="si_creador" attrs="{'readonly': True}" /> <field name="si_creador" attrs="{'readonly': True}" />
<field name="si_mensaje" attrs="{'readonly': True}" /> <field name="si_mensaje" attrs="{'readonly': True}" />
<field name="si_mens_fecha" attrs="{'readonly': True}" />
</tree> </tree>
</field> </field>
</group> </group>
...@@ -93,6 +95,8 @@ ...@@ -93,6 +95,8 @@
<field name="arch" type="xml"> <field name="arch" type="xml">
<search> <search>
<field name="si_name" /> <field name="si_name" />
<field name="si_descripcion" />
<field name="si_fecha" />
</search> </search>
</field> </field>
</record> </record>
......
...@@ -2,17 +2,16 @@ ...@@ -2,17 +2,16 @@
<odoo> <odoo>
<data noupdate="0"> <data noupdate="0">
<!-- Elemento Root --> <!-- Elemento Root -->
<menuitem name="Soporte" sequence='10' id="hgt_soporte_soporte"/> <menuitem name="Soporte" sequence='97' id="hgt_soporte_soporte"/>
<!-- Elemento Grupe --> <!-- Elemento Grupe -->
<menuitem name="Incidencias Propias" sequence="10" id="hgt_soporte_incidencias_propias" parent="hgt_soporte_soporte"/> <menuitem name="Incidencias Propias" sequence="10" id="hgt_soporte_incidencias_propias" parent="hgt_soporte_soporte"/>
<menuitem name="Representante Técnico" sequence="20" id="hgt_soporte_representante_tecnico" parent="hgt_soporte_soporte"/> <menuitem name="Representante Técnico" sequence="20" id="hgt_soporte_representante_tecnico" parent="hgt_soporte_soporte"/>
<menuitem name="Incidencias" <menuitem name="Mis Incidencias"
sequence="10" sequence="10"
id="hgt_soporte_incidencias_propias_incidencias" id="hgt_soporte_incidencias_propias_incidencias"
parent="hgt_soporte_incidencias_propias" parent="hgt_soporte_incidencias_propias"
action="action_soporteincidencias_act_window" action="action_soporteincidencias_act_window"/>
groups="group_soporte_general,group_soporte_configurador"/>
<menuitem name="Incidencias" <menuitem name="Incidencias"
sequence="10" sequence="10"
......
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from . import generarmensaje
\ No newline at end of file \ No newline at end of file
# -*- coding: utf-8 -*-
from odoo import models, fields, api
from odoo.exceptions import UserError
from datetime import datetime
class tpv_generar_nota(models.TransientModel):
_name = 'soporte.mensaje_wiz'
_description = 'Generar Nota'
incidencia = fields.Many2one(
string=u'incidencia origen',
comodel_name='hgt.soporte_incidencia',
)
texto = fields.Text(string='Mensaje')
def Generarmensajeinterno(self):
if self.texto == False:
raise UserError("No puso ningun mensaje")
mensaje = self.env["hgt.soporte_mensaje"].create({})
mensaje.si_incidencias = [self.incidencia.id]
mensaje.si_mensaje = self.texto
def generar_notaCred(self):
return {
'name': "Nota de Débito",
'type': 'ir.actions.act_window',
'res_model': 'asw.comprobante',
'view_mode': 'form',
'view_type': 'form',
'res_id': contra_comprobante.id,
'target': 'self',
}
<?xml version='1.0' encoding='utf-8'?>
<odoo>
<data noupdate="0">
<record id="tpv_generar_nota_wizzard_view_form" model="ir.ui.view">
<field name="name">Enviar mensaje</field>
<field name="model">soporte.mensaje_wiz</field>
<field name="arch" type="xml">
<form>
<group col='4'>
<field name="texto"/>
</group>
<div style='text-align:center'>
<button name="EnviarMensajeSoporte" class="btn btn-info" string="Enviar mensaje a HGT" type="object" />
<button name="Generarmensajeinterno" class="btn btn-success" string="Mensaje interno" type="object" />
</div>
<footer>
<button special='cancel' string="Cancelar"/>
</footer>
</form>
</field>
</record>
<!-- soporte.mensaje_wiz action window -->
<record id="tpv_generar_nota_wizzard_action" model="ir.actions.act_window">
<field name="name">Generar Mensaje</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">soporte.mensaje_wiz</field>
<field name="src_model">soporte.mensaje_wiz</field>
<field name="view_mode">form</field>
<field name="target">new</field>
<field name="multi">True</field>
</record>
</data>
</odoo>
\ No newline at end of file \ No newline at end of file
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!