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