Fix - Buscar por clave
This commit is contained in:
parent
f8afdcc59a
commit
498a496cd9
|
@ -1710,8 +1710,9 @@ class Productos(BaseModel):
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_by(cls, values):
|
def get_by(cls, values):
|
||||||
id = int(values.get('id', 0))
|
# ~ id = int(values.get('id', 0))
|
||||||
if id:
|
clave = values.get('id', '')
|
||||||
|
if clave:
|
||||||
row = (Productos
|
row = (Productos
|
||||||
.select(
|
.select(
|
||||||
Productos.id,
|
Productos.id,
|
||||||
|
@ -1722,8 +1723,9 @@ class Productos(BaseModel):
|
||||||
Productos.valor_unitario,
|
Productos.valor_unitario,
|
||||||
Productos.descuento)
|
Productos.descuento)
|
||||||
.join(SATUnidades).switch(Productos)
|
.join(SATUnidades).switch(Productos)
|
||||||
.where(Productos.id==id).dicts())
|
.where(Productos.clave==clave).dicts())
|
||||||
if len(row):
|
if len(row):
|
||||||
|
id = row[0]['id']
|
||||||
model_pt = Productos.impuestos.get_through_model()
|
model_pt = Productos.impuestos.get_through_model()
|
||||||
taxes = tuple(model_pt
|
taxes = tuple(model_pt
|
||||||
.select(
|
.select(
|
||||||
|
@ -1731,6 +1733,8 @@ class Productos(BaseModel):
|
||||||
model_pt.satimpuestos_id.alias('tax'))
|
model_pt.satimpuestos_id.alias('tax'))
|
||||||
.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', '')
|
||||||
|
@ -1745,7 +1749,8 @@ class Productos(BaseModel):
|
||||||
Productos.valor_unitario)
|
Productos.valor_unitario)
|
||||||
.join(SATUnidades)
|
.join(SATUnidades)
|
||||||
.switch(Productos)
|
.switch(Productos)
|
||||||
.where(Productos.descripcion.contains(name))
|
.where((Productos.descripcion.contains(name)) |
|
||||||
|
(Productos.clave.contains(name)))
|
||||||
.dicts()
|
.dicts()
|
||||||
)
|
)
|
||||||
return tuple(rows)
|
return tuple(rows)
|
||||||
|
|
Loading…
Reference in New Issue