Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Maria Agustina
/
hgt_transportar
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 fe7781e0
authored
2021-11-07 12:34:52 -0300
by
adrian
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
productivo
1 parent
a4c312a2
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
96 additions
and
36 deletions
controllers/controllers.py
models/transportista.py
views/transportista_vista.xml
controllers/controllers.py
View file @
fe7781e
...
@@ -10,15 +10,11 @@ class dispositivos(http.Controller):
...
@@ -10,15 +10,11 @@ class dispositivos(http.Controller):
@http.route
(
'/lappa/localidades/sugerencia'
,
auth
=
'public'
,
type
=
'json'
,
website
=
True
,
csrf
=
False
,
methods
=
[
'POST'
,
'GET'
])
@http.route
(
'/lappa/localidades/sugerencia'
,
auth
=
'public'
,
type
=
'json'
,
website
=
True
,
csrf
=
False
,
methods
=
[
'POST'
,
'GET'
])
def
index
(
self
,
**
kw
):
def
index
(
self
,
**
kw
):
#print(kw)
registro
=
http
.
request
.
env
[
'asw.localidad'
]
.
sudo
()
registro
=
http
.
request
.
env
[
'asw.localidad'
]
.
sudo
()
palabra
=
argentinidad
.
arg
(
kw
[
"localidad"
])
#adapto el diccionario de busqueda
palabra
=
argentinidad
.
arg
(
kw
[
"localidad"
])
dominio
=
[[
"buscador"
,
"ilike"
,
palabra
]]
dominio
=
[[
"buscador"
,
"ilike"
,
palabra
]]
#print(dominio, registro)
#dominio.append(["active","=",True])
localidades
=
registro
.
search
(
dominio
,
limit
=
10
)
localidades
=
registro
.
search
(
dominio
,
limit
=
10
)
resultado
=
[]
resultado
=
[]
#print(localidades)
for
localidad
in
localidades
:
for
localidad
in
localidades
:
loc
=
{
loc
=
{
"name"
:
localidad
.
name
,
"name"
:
localidad
.
name
,
...
@@ -30,15 +26,11 @@ class dispositivos(http.Controller):
...
@@ -30,15 +26,11 @@ class dispositivos(http.Controller):
@http.route
(
'/lappa/localidades/sugerenciaget'
,
auth
=
'public'
,
type
=
'http'
,
website
=
True
,
csrf
=
False
,
methods
=
[
'POST'
,
'GET'
])
@http.route
(
'/lappa/localidades/sugerenciaget'
,
auth
=
'public'
,
type
=
'http'
,
website
=
True
,
csrf
=
False
,
methods
=
[
'POST'
,
'GET'
])
def
buscador
(
self
,
**
kw
):
def
buscador
(
self
,
**
kw
):
#print(kw)
registro
=
http
.
request
.
env
[
'asw.localidad'
]
.
sudo
()
registro
=
http
.
request
.
env
[
'asw.localidad'
]
.
sudo
()
palabra
=
argentinidad
.
arg
(
kw
[
"localidad"
])
#adapto el diccionario de busqueda
palabra
=
argentinidad
.
arg
(
kw
[
"localidad"
])
dominio
=
[[
"buscador"
,
"ilike"
,
palabra
]]
dominio
=
[[
"buscador"
,
"ilike"
,
palabra
]]
#print(dominio, registro)
#dominio.append(["active","=",True])
localidades
=
registro
.
search
(
dominio
,
limit
=
10
)
localidades
=
registro
.
search
(
dominio
,
limit
=
10
)
resultado
=
[]
resultado
=
[]
#print(localidades)
for
localidad
in
localidades
:
for
localidad
in
localidades
:
loc
=
{
loc
=
{
"name"
:
localidad
.
name
,
"name"
:
localidad
.
name
,
...
@@ -49,7 +41,6 @@ class dispositivos(http.Controller):
...
@@ -49,7 +41,6 @@ class dispositivos(http.Controller):
@http.route
(
'/lappa/transportista/buscadorget'
,
auth
=
'public'
,
type
=
'http'
,
website
=
True
,
csrf
=
False
,
methods
=
[
'POST'
,
'GET'
])
@http.route
(
'/lappa/transportista/buscadorget'
,
auth
=
'public'
,
type
=
'http'
,
website
=
True
,
csrf
=
False
,
methods
=
[
'POST'
,
'GET'
])
def
transportista
(
self
,
**
kw
):
def
transportista
(
self
,
**
kw
):
#print(kw)
try
:
try
:
pagina
=
int
(
kw
[
"pagina"
])
pagina
=
int
(
kw
[
"pagina"
])
except
:
except
:
...
@@ -79,18 +70,9 @@ class dispositivos(http.Controller):
...
@@ -79,18 +70,9 @@ class dispositivos(http.Controller):
tranportistas
=
[]
tranportistas
=
[]
while
not
contador
==
paginado
:
while
not
contador
==
paginado
:
try
:
try
:
#print(inicial+contador)
tranportistas
.
append
(
lista
[
inicial
+
contador
])
tranportistas
.
append
(
lista
[
inicial
+
contador
])
except
:
except
:
pass
pass
#tranportistas = []
#cont = 0
#for transportista in lista:
# cont = cont + 1
# tranportistas.append(transportista)
# print(contador, transportista)
# if cont == paginado:
# break
contador
=
contador
+
1
contador
=
contador
+
1
return
(
tranportistas
)
return
(
tranportistas
)
...
@@ -114,7 +96,6 @@ class dispositivos(http.Controller):
...
@@ -114,7 +96,6 @@ class dispositivos(http.Controller):
return
(
lista1
,
origen
,
destino
)
return
(
lista1
,
origen
,
destino
)
def
extraerdatosTrans
(
self
,
transportista
):
def
extraerdatosTrans
(
self
,
transportista
):
#print(transportista)
cat
=
{
"np"
:
False
,
"p"
:
True
}
cat
=
{
"np"
:
False
,
"p"
:
True
}
dato
=
{
"id"
:
transportista
.
id
}
dato
=
{
"id"
:
transportista
.
id
}
dato
[
"web"
]
=
transportista
.
trans_pagina_web
dato
[
"web"
]
=
transportista
.
trans_pagina_web
...
@@ -122,12 +103,8 @@ class dispositivos(http.Controller):
...
@@ -122,12 +103,8 @@ class dispositivos(http.Controller):
dato
[
"nombre"
]
=
transportista
.
trans_nombre
dato
[
"nombre"
]
=
transportista
.
trans_nombre
dato
[
"telefono"
]
=
transportista
.
trans_telefono
dato
[
"telefono"
]
=
transportista
.
trans_telefono
dato
[
"email"
]
=
transportista
.
trans_email
dato
[
"email"
]
=
transportista
.
trans_email
dato
[
"logo"
]
=
"http://hgtarg.com/logo.jpg"
dato
[
"logo"
]
=
transportista
.
url_logo_trans
()
#
"http://hgtarg.com/logo.jpg"
dato
[
"categoria"
]
=
cat
[
transportista
.
trans_categoria
]
dato
[
"categoria"
]
=
cat
[
transportista
.
trans_categoria
]
#dato[""] = ransportista.
#dato[""] = ransportista.
#dato[""] = ransportista.
#dato[""] = ransportista.
return
(
dato
)
return
(
dato
)
def
TransportistaLocalidad
(
self
,
loc_id
):
def
TransportistaLocalidad
(
self
,
loc_id
):
...
@@ -149,7 +126,7 @@ class dispositivos(http.Controller):
...
@@ -149,7 +126,7 @@ class dispositivos(http.Controller):
loc_orig
=
kw
[
"id_localidad_origen"
]
loc_orig
=
kw
[
"id_localidad_origen"
]
loc_dest
=
kw
[
"id_localidad_destino"
]
loc_dest
=
kw
[
"id_localidad_destino"
]
trans
=
http
.
request
.
env
[
'trans.transportista'
]
.
sudo
()
.
search
([[
"id"
,
"="
,
kw
[
"id_transportista"
]]])
trans
=
http
.
request
.
env
[
'trans.transportista'
]
.
sudo
()
.
search
([[
"id"
,
"="
,
kw
[
"id_transportista"
]]])
print
(
trans
)
#Implimentar Randon en busqueda
datos
=
{}
datos
=
{}
cat
=
{
"np"
:
False
,
"p"
:
True
}
cat
=
{
"np"
:
False
,
"p"
:
True
}
datos
[
"datos_generales"
]
=
{
"id"
:
kw
[
"id_transportista"
],
datos
[
"datos_generales"
]
=
{
"id"
:
kw
[
"id_transportista"
],
...
@@ -158,7 +135,7 @@ class dispositivos(http.Controller):
...
@@ -158,7 +135,7 @@ class dispositivos(http.Controller):
"nombre"
:
trans
.
trans_nombre
,
"nombre"
:
trans
.
trans_nombre
,
"telefono"
:
trans
.
trans_telefono
,
"telefono"
:
trans
.
trans_telefono
,
"email"
:
trans
.
trans_email
,
"email"
:
trans
.
trans_email
,
"logo"
:
"http://hgtarg.com/logo.jpg"
,
"logo"
:
trans
.
url_logo_trans
()
,
"categoria"
:
cat
[
trans
.
trans_categoria
]}
"categoria"
:
cat
[
trans
.
trans_categoria
]}
datos
[
"datos_origen"
]
=
self
.
GetDatosPR
(
kw
[
"id_localidad_origen"
],
trans
.
trans_pto_retiro
)
datos
[
"datos_origen"
]
=
self
.
GetDatosPR
(
kw
[
"id_localidad_origen"
],
trans
.
trans_pto_retiro
)
datos
[
"datos_destino"
]
=
self
.
GetDatosPR
(
kw
[
"id_localidad_destino"
],
trans
.
trans_pto_retiro
)
datos
[
"datos_destino"
]
=
self
.
GetDatosPR
(
kw
[
"id_localidad_destino"
],
trans
.
trans_pto_retiro
)
...
@@ -185,9 +162,7 @@ class dispositivos(http.Controller):
...
@@ -185,9 +162,7 @@ class dispositivos(http.Controller):
oscuro
=
"https://hgtarg.com/lappa/Principal
%20
oscuro.jpg"
oscuro
=
"https://hgtarg.com/lappa/Principal
%20
oscuro.jpg"
camion
=
"https://hgtarg.com/lappa/camion.png"
camion
=
"https://hgtarg.com/lappa/camion.png"
tilde
=
"https://hgtarg.com/lappa/tilde.png"
tilde
=
"https://hgtarg.com/lappa/tilde.png"
data
=
{
"claro"
:
claro
,
"oscuro"
:
oscuro
,
"camion"
:
camion
,
"tilde"
:
tilde
}
data
=
{
"claro"
:
claro
,
"oscuro"
:
oscuro
,
"camion"
:
camion
,
"tilde"
:
tilde
}
data
[
"fondo"
]
=
claro
data
[
"fondo"
]
=
claro
return
(
json
.
dumps
(
data
))
return
(
json
.
dumps
(
data
))
models/transportista.py
View file @
fe7781e
# -*- coding: utf-8 -*-
# -*- coding: utf-8 -*-
from
odoo
import
models
,
fields
,
api
,
exceptions
from
odoo
import
models
,
fields
,
api
,
exceptions
from
datetime
import
datetime
from
datetime
import
datetime
import
base64
,
requests
vista_previa
=
"""<h2>Vista Previa</h2>
<img src="{}" alt="Previsualizacion" style="max-height: 400px; max-width: 400px;"/>
<h2>Publicado</h2>
<img src="{}" alt="Previsualizacion" style="max-height: 400px; max-width: 400px;"/>
"""
class
trans_transportista
(
models
.
Model
):
class
trans_transportista
(
models
.
Model
):
_name
=
'trans.transportista'
_name
=
'trans.transportista'
_description
=
'Transportista'
_description
=
'Transportista'
...
@@ -30,6 +36,10 @@ class trans_transportista(models.Model):
...
@@ -30,6 +36,10 @@ class trans_transportista(models.Model):
help
=
'Archivo png o jpg de menos de 2 Mb'
help
=
'Archivo png o jpg de menos de 2 Mb'
)
)
trans_logo_nombre
=
fields
.
Char
(
string
=
u'Logo'
,
help
=
'Archivo png o jpg de menos de 2 Mb'
)
trans_categoria
=
fields
.
Selection
(
trans_categoria
=
fields
.
Selection
(
string
=
u'Categoría'
,
string
=
u'Categoría'
,
selection
=
[(
'p'
,
'Paga'
),
(
'np'
,
'No Paga'
)],
selection
=
[(
'p'
,
'Paga'
),
(
'np'
,
'No Paga'
)],
...
@@ -92,8 +102,36 @@ class trans_transportista(models.Model):
...
@@ -92,8 +102,36 @@ class trans_transportista(models.Model):
imagen
=
fields
.
Binary
(
string
=
'Logo'
)
imagen
=
fields
.
Binary
(
string
=
'Logo'
)
soy_admin
=
fields
.
Char
(
string
=
'Soy adminstrador de LAPPA'
,
compute
=
"_soy_administrador"
)
url_img
=
fields
.
Char
(
string
=
'URL imagen'
)
url_img_publica
=
fields
.
Char
(
string
=
'URL imagen'
)
publicada_img
=
fields
.
Selection
(
string
=
'Publicar imagen'
,
selection
=
[
(
'sa'
,
'Sin Autorizar'
),
(
'a'
,
'Autorizado'
),],
required
=
True
,
default
=
"sa"
)
muestra
=
fields
.
Html
(
string
=
'Previsualizador'
,
compute
=
"_compute_prev"
,
sanitize
=
False
)
def
_compute_prev
(
self
):
#print(dir(self.trans_logo), self.trans_logo, dir(self.imagen))
imagen
=
"http://hgtarg.com/logo.jpg"
if
(
self
.
trans_categoria
==
"p"
)
and
(
not
(
self
.
url_img_publica
==
False
or
self
.
url_img_publica
==
""
)):
imagen
=
self
.
url_img_publica
self
.
muestra
=
vista_previa
.
format
(
self
.
url_img
,
imagen
)
#@api.depends('ejecutor')
def
_soy_administrador
(
self
):
if
self
.
env
.
user
.
has_group
(
"hgt_transportar.module_group_administrador"
):
self
.
soy_admin
=
"Soy adinistrador"
else
:
self
.
soy_admin
=
""
@api.one
@api.one
@api.constrains
(
'trans_cuit'
,
'trans_telefono'
)
@api.constrains
(
'trans_cuit'
,
'trans_telefono'
)
def
_requerir_valores
(
self
):
def
_requerir_valores
(
self
):
...
@@ -233,9 +271,46 @@ class trans_transportista(models.Model):
...
@@ -233,9 +271,46 @@ class trans_transportista(models.Model):
puntos
.
append
(
punto_retiro
.
pr_localidad
.
id
)
#si no esta en la lista agrego la localidad en la lista puntos cargados
puntos
.
append
(
punto_retiro
.
pr_localidad
.
id
)
#si no esta en la lista agrego la localidad en la lista puntos cargados
#print(puntos)
#print(puntos)
def
publicar
(
self
):
def
subir_img
(
self
):
decoded_image_data
=
base64
.
decodebytes
(
self
.
trans_logo
)
path
=
requests
.
post
(
url
=
"https://img.hgtsa.com.ar/"
,
files
=
{
'data'
:
(
self
.
trans_logo_nombre
,
decoded_image_data
)
})
ruta
=
"https://img.hgtsa.com.ar/"
+
path
.
text
self
.
url_img
=
ruta
@api.onchange
(
'trans_logo'
)
def
_onchange_trans_logo
(
self
):
#registro = self.env['trans.transportista'].browse(self._origin.id)
#try:
# registro.subir_img()
#except Exception as e:
# print(e)
pass
pass
def
previsualizar_imagen
(
self
):
if
self
.
trans_logo
:
self
.
subir_img
()
else
:
raise
exceptions
.
Warning
(
"No se ha cargado imagen para actualizar"
)
def
comprar
(
self
):
def
comprar
(
self
):
pass
pass
def
publicar
(
self
):
if
self
.
trans_categoria
==
"np"
:
raise
exceptions
.
Warning
(
"No se puede publicar si no es un abonado"
)
if
(
self
.
url_img
==
False
)
or
(
self
.
url_img
==
""
):
raise
exceptions
.
Warning
(
"Primero deve previsualizar la imagen de manera correcta"
)
self
.
url_img_publica
=
self
.
url_img
self
.
publicada_img
=
"a"
def
quitar_imagen
(
self
):
self
.
url_img_publica
=
False
self
.
publicada_img
=
"sa"
def
url_logo_trans
(
self
):
print
(
"Inafsdf"
)
if
self
.
publicada_img
==
"a"
:
return
(
self
.
url_img_publica
)
else
:
return
(
"http://hgtarg.com/logo.jpg"
)
\ No newline at end of file
\ No newline at end of file
views/transportista_vista.xml
View file @
fe7781e
...
@@ -24,7 +24,6 @@
...
@@ -24,7 +24,6 @@
<form>
<form>
<header>
<header>
<button
name=
"deduplicar_pr"
class=
'btn btn-warning'
string=
"Quitar puntos de retiro duplicados"
type=
"object"
/>
<button
name=
"deduplicar_pr"
class=
'btn btn-warning'
string=
"Quitar puntos de retiro duplicados"
type=
"object"
/>
<button
name=
"publicar"
class=
'btn btn-warning'
string=
"Publicar imagen"
type=
"object"
/>
<button
name=
"comprar"
class=
'btn btn-info'
string=
"Comprar membresia"
type=
"object"
/>
<button
name=
"comprar"
class=
'btn btn-info'
string=
"Comprar membresia"
type=
"object"
/>
</header>
</header>
<sheet>
<sheet>
...
@@ -34,17 +33,28 @@
...
@@ -34,17 +33,28 @@
<field
name=
"trans_cuit"
colspan=
"2"
required=
"1"
/>
<field
name=
"trans_cuit"
colspan=
"2"
required=
"1"
/>
</group>
</group>
<group
col=
"2"
string=
"Imagen"
>
<group
col=
"2"
string=
"Imagen"
>
<field
name=
"imagen"
widget=
'image'
options=
"{'preview_image': 'image_small', 'size': [30, 30]}"
/>
<field
name=
"trans_logo_nombre"
invisible=
"1"
/>
<field
name=
"trans_logo"
widget=
"file"
filename=
"trans_logo_nombre"
/>
<field
name=
"soy_admin"
nolabel=
"1"
/>
</group>
<group
col=
"4"
string=
"Imagen Administracion"
attrs=
"{'invisible': [('soy_admin','!=','Soy adinistrador')]}"
>
<button
name=
"previsualizar_imagen"
class=
'btn btn-success'
string=
"Previsualizar imagen"
type=
"object"
/>
<button
name=
"publicar"
class=
'btn btn-warning'
string=
"Publicar imagen"
type=
"object"
/>
<button
name=
"quitar_imagen"
class=
'btn btn-danger'
string=
"Quitar imagen"
type=
"object"
/>
<field
name=
"url_img"
nolabel=
"1"
colspan=
"4"
/>
<field
name=
"publicada_img"
colspan=
"4"
/>
<field
name=
"muestra"
nolabel=
"1"
/>
</group>
</group>
<group
col=
"2"
string=
"Datos de contacto"
>
<group
col=
"2"
string=
"Datos de contacto"
>
<field
name=
"trans_telefono"
colspan=
"2"
required=
"1"
/>
<field
name=
"trans_telefono"
colspan=
"2"
required=
"1"
/>
<field
name=
"trans_email"
widget=
"email"
colspan=
"2"
/>
<field
name=
"trans_email"
widget=
"email"
colspan=
"2"
/>
<field
name=
"trans_pagina_web"
colspan=
"2"
/>
<field
name=
"trans_pagina_web"
colspan=
"2"
/>
<field
name=
"trans_logo"
colspan=
"2"
/>
<field
name=
"imagen"
colspan=
"2"
/>
</group>
</group>
<group
col=
"2"
string=
"Características del transporte"
>
<group
col=
"2"
string=
"Características del transporte"
>
<field
name=
"trans_tipo_ent"
colspan=
"2"
required=
"1"
/>
<field
name=
"trans_tipo_ent"
colspan=
"2"
required=
"1"
/>
<field
name=
"trans_tipo"
placeholder=
"Tipo de transporte"
widget=
"many2many_tags"
nolabel=
"1"
colspan=
"2"
/>
<field
name=
"trans_tipo"
placeholder=
"Tipo de transporte"
widget=
"many2many_tags"
colspan=
"2"
/>
<field
name=
"trans_restriccion_elem"
colspan=
"2"
/>
<field
name=
"trans_restriccion_elem"
colspan=
"2"
/>
<!-- <field name="trans_pto_retiro" nolabel="1" colspan="2" /> -->
<!-- <field name="trans_pto_retiro" nolabel="1" colspan="2" /> -->
<field
name=
"trans_posee_ayu"
colspan=
"2"
/>
<field
name=
"trans_posee_ayu"
colspan=
"2"
/>
...
...
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