Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Maria Agustina
/
hgt_soporte
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
Commit dbf2598b
authored
2022-12-09 10:35:23 -0300
by
juan
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Cliente resive adjuntos
1 parent
e99f2c84
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
64 additions
and
17 deletions
models/adjuntos.py
models/incidencia.py
models/adjuntos.py
View file @
dbf2598
# -*- coding: utf-8 -*-
# -*- coding: utf-8 -*-
from
odoo
import
models
,
fields
,
api
from
odoo
import
models
,
fields
,
api
import
datetime
import
requests
,
json
from
datetime
import
datetime
from
datetime
import
datetime
headers
=
{
'Content-Type'
:
'application/json'
}
class
hgt_soporte_adjunto
(
models
.
Model
):
class
hgt_soporte_adjunto
(
models
.
Model
):
_name
=
'hgt.soporte_adjunto'
_name
=
'hgt.soporte_adjunto'
...
@@ -46,10 +47,13 @@ class hgt_soporte_adjunto(models.Model):
...
@@ -46,10 +47,13 @@ class hgt_soporte_adjunto(models.Model):
self
.
name
=
f
"""{self.CodigoBase()}_{str(self.id).zfill(5)}"""
self
.
name
=
f
"""{self.CodigoBase()}_{str(self.id).zfill(5)}"""
def
DescargarArchivo
(
self
):
def
DescargarArchivo
(
self
):
vals
=
{
if
self
.
remoto
:
"file_name"
:
self
.
file_name
,
vals
=
self
.
BuscarArchivoRemoto
()
"file"
:
self
.
file
,
else
:
}
vals
=
{
"file_name"
:
self
.
file_name
,
"file"
:
self
.
file
,
}
adjunto
=
self
.
env
[
'soporte.descarga_wiz'
]
.
create
(
vals
)
adjunto
=
self
.
env
[
'soporte.descarga_wiz'
]
.
create
(
vals
)
return
{
return
{
'name'
:
"Adjunto"
,
'name'
:
"Adjunto"
,
...
@@ -60,6 +64,23 @@ class hgt_soporte_adjunto(models.Model):
...
@@ -60,6 +64,23 @@ class hgt_soporte_adjunto(models.Model):
'res_id'
:
adjunto
.
id
,
'res_id'
:
adjunto
.
id
,
'target'
:
'new'
,
'target'
:
'new'
,
}
}
def
BuscarArchivoRemoto
(
self
):
database
=
self
.
env
.
cr
.
dbname
datos
=
{
'params'
:
{
'token'
:
self
.
incidencia
.
GenerarToken
(),
'name'
:
self
.
name
}
}
datos_json
=
json
.
dumps
(
datos
)
f
=
requests
.
post
(
f
"{self.incidencia.UrlBaseHGT()}soporteIncidencias/BajarAdjunto"
,
data
=
datos_json
,
headers
=
headers
)
frespuesta
=
f
.
json
()
#print(frespuesta,f"{self.incidencia.UrlBaseHGT()}soporteIncidencias/BajarAdjunto")
vals
=
{
"file_name"
:
frespuesta
[
"result"
][
0
][
"file_name"
],
"file"
:
frespuesta
[
"result"
][
0
][
"file"
],
}
return
(
vals
)
models/incidencia.py
View file @
dbf2598
...
@@ -12,8 +12,8 @@ TokensValidos = [
...
@@ -12,8 +12,8 @@ TokensValidos = [
"asdASFefcECWÑlfweñ324dcfwcfdwefcñfdwqecwedfñfc43fd.dfqwe,dfweqf3cvbtr.LDSFsdfsaewfvresf"
,
"asdASFefcECWÑlfweñ324dcfwcfdwefcñfdwqecwedfñfc43fd.dfqwe,dfweqf3cvbtr.LDSFsdfsaewfvresf"
,
"dsfrvvcmopñ{ds {frew}ferfcv-43wef765ÑFDGg34g3bafGFDhgfHTRvvdsDFFSdfghhfghtVCSdr345Fesdf"
,
"dsfrvvcmopñ{ds {frew}ferfcv-43wef765ÑFDGg34g3bafGFDhgfHTRvvdsDFFSdfghhfghtVCSdr345Fesdf"
,
]
]
HgtUrlBase
=
"""https://hgt.hgt.com.ar/"""
#
HgtUrlBase = """https://hgt.hgt.com.ar/"""
#
HgtUrlBase = """https://validacion.hgtsa.com.ar/"""
HgtUrlBase
=
"""https://validacion.hgtsa.com.ar/"""
class
hgt_soporte_incidencia
(
models
.
Model
):
class
hgt_soporte_incidencia
(
models
.
Model
):
_name
=
'hgt.soporte_incidencia'
_name
=
'hgt.soporte_incidencia'
...
@@ -402,13 +402,14 @@ class hgt_soporte_incidencia(models.Model):
...
@@ -402,13 +402,14 @@ class hgt_soporte_incidencia(models.Model):
return
(
None
)
return
(
None
)
lista
=
[]
lista
=
[]
for
adj
in
self
.
adjunto
:
for
adj
in
self
.
adjunto
:
val
=
{
if
adj
.
remoto
==
False
:
"usuario"
:
adj
.
usuario
,
val
=
{
"file_name"
:
adj
.
file_name
,
"usuario"
:
adj
.
usuario
,
"name"
:
adj
.
name
,
"file_name"
:
adj
.
file_name
,
"fecha"
:
adj
.
fecha
,
"name"
:
adj
.
name
,
}
"fecha"
:
adj
.
fecha
,
lista
.
append
(
val
)
}
lista
.
append
(
val
)
database
=
self
.
env
.
cr
.
dbname
database
=
self
.
env
.
cr
.
dbname
datos
=
{
datos
=
{
...
@@ -427,13 +428,38 @@ class hgt_soporte_incidencia(models.Model):
...
@@ -427,13 +428,38 @@ class hgt_soporte_incidencia(models.Model):
if
frespuesta
[
"result"
][
"estado"
]
!=
"ok"
:
if
frespuesta
[
"result"
][
"estado"
]
!=
"ok"
:
raise
UserError
(
str
(
frespuesta
))
raise
UserError
(
str
(
frespuesta
))
def
LaikaSoporteAdjunto
(
self
,
opt
):
incidencia
=
self
.
search
([[
"si_name"
,
"="
,
opt
[
"si_name"
]]])
#print(opt)
for
adjunto
in
opt
[
"adjuntos"
]:
self
.
AgregarAdjuntosSoporte
(
adjunto
,
incidencia
)
def
AgregarAdjuntosSoporte
(
self
,
adjunto
,
incidencia
):
"""Chequeo si el adjunto existe sino lo creo"""
dom
=
[
[
"incidencia"
,
"="
,
incidencia
.
id
],
[
"name"
,
"="
,
adjunto
[
"name"
]]
]
test
=
self
.
env
[
"hgt.soporte_adjunto"
]
.
search
(
dom
)
#print(dom, test)
if
len
(
test
)
!=
0
:
return
(
None
)
#Sino existe la creo
val
=
{}
val
[
"remoto"
]
=
True
val
[
"incidencia"
]
=
incidencia
.
id
#Relacion inversa cxon la incidencia
val
[
"usuario"
]
=
adjunto
[
"usuario"
]
val
[
"file_name"
]
=
adjunto
[
"file_name"
]
val
[
"fecha"
]
=
adjunto
[
"fecha"
]
val
[
"name"
]
=
adjunto
[
"name"
]
print
(
val
)
self
.
env
[
"hgt.soporte_adjunto"
]
.
create
(
val
)
def
UrlBaseHGT
(
self
):
return
(
HgtUrlBase
)
...
...
Write
Preview
Styling with
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment