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
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
53 additions
and
6 deletions
models/adjuntos.py
models/incidencia.py
models/adjuntos.py
View file @
dbf2598
# -*- coding: utf-8 -*-
from
odoo
import
models
,
fields
,
api
import
datetime
import
requests
,
json
from
datetime
import
datetime
headers
=
{
'Content-Type'
:
'application/json'
}
class
hgt_soporte_adjunto
(
models
.
Model
):
_name
=
'hgt.soporte_adjunto'
...
...
@@ -46,6 +47,9 @@ class hgt_soporte_adjunto(models.Model):
self
.
name
=
f
"""{self.CodigoBase()}_{str(self.id).zfill(5)}"""
def
DescargarArchivo
(
self
):
if
self
.
remoto
:
vals
=
self
.
BuscarArchivoRemoto
()
else
:
vals
=
{
"file_name"
:
self
.
file_name
,
"file"
:
self
.
file
,
...
...
@@ -61,5 +65,22 @@ class hgt_soporte_adjunto(models.Model):
'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 = [
"asdASFefcECWÑlfweñ324dcfwcfdwefcñfdwqecwedfñfc43fd.dfqwe,dfweqf3cvbtr.LDSFsdfsaewfvresf"
,
"dsfrvvcmopñ{ds {frew}ferfcv-43wef765ÑFDGg34g3bafGFDhgfHTRvvdsDFFSdfghhfghtVCSdr345Fesdf"
,
]
HgtUrlBase
=
"""https://hgt.hgt.com.ar/"""
#
HgtUrlBase = """https://validacion.hgtsa.com.ar/"""
#
HgtUrlBase = """https://hgt.hgt.com.ar/"""
HgtUrlBase
=
"""https://validacion.hgtsa.com.ar/"""
class
hgt_soporte_incidencia
(
models
.
Model
):
_name
=
'hgt.soporte_incidencia'
...
...
@@ -402,6 +402,7 @@ class hgt_soporte_incidencia(models.Model):
return
(
None
)
lista
=
[]
for
adj
in
self
.
adjunto
:
if
adj
.
remoto
==
False
:
val
=
{
"usuario"
:
adj
.
usuario
,
"file_name"
:
adj
.
file_name
,
...
...
@@ -427,13 +428,38 @@ class hgt_soporte_incidencia(models.Model):
if
frespuesta
[
"result"
][
"estado"
]
!=
"ok"
:
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