Fix - Issue #129

This commit is contained in:
Mauricio Baeza 2018-01-17 23:29:56 -06:00
commit bae8af881e
1 changed files with 8 additions and 6 deletions

View File

@ -2146,7 +2146,8 @@ class Productos(BaseModel):
Productos.valor_unitario, Productos.valor_unitario,
Productos.descuento) Productos.descuento)
.join(SATUnidades).switch(Productos) .join(SATUnidades).switch(Productos)
.where((Productos.clave==clave) | (Productos.codigo_barras==clave)) .where((Productos.es_activo==True) &
((Productos.clave==clave) | (Productos.codigo_barras==clave)))
.dicts() .dicts()
) )
if len(row): if len(row):
@ -2175,7 +2176,8 @@ class Productos(BaseModel):
Productos.valor_unitario, Productos.valor_unitario,
Productos.descuento) Productos.descuento)
.join(SATUnidades).switch(Productos) .join(SATUnidades).switch(Productos)
.where((Productos.id==clave) | (Productos.clave==clave)) .where((Productos.es_activo==True) &
((Productos.id==clave) | (Productos.clave==clave)))
.dicts()) .dicts())
if len(row): if len(row):
id = row[0]['id'] id = row[0]['id']
@ -2187,10 +2189,10 @@ class Productos(BaseModel):
.where(model_pt.productos_id==id).dicts()) .where(model_pt.productos_id==id).dicts())
return {'ok': True, 'row': row[0], 'taxes': taxes} return {'ok': True, 'row': row[0], 'taxes': taxes}
return {'ok': False} return {'ok': False}
name = values.get('name', '') name = values.get('name', '')
print (name)
if name: if name:
rows = (Productos rows = (Productos
.select( .select(
@ -2202,9 +2204,9 @@ class Productos(BaseModel):
Productos.valor_unitario) Productos.valor_unitario)
.join(SATUnidades) .join(SATUnidades)
.switch(Productos) .switch(Productos)
.where( .where((Productos.es_activo==True) &
(Productos.descripcion.contains(name)) | ((Productos.descripcion.contains(name)) |
(Productos.clave.contains(name))) (Productos.clave.contains(name))))
.dicts() .dicts()
) )
return tuple(rows) return tuple(rows)