forked from elmau/empresa-libre
commit
bd73871cb0
|
@ -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)
|
||||
|
|
|
@ -435,9 +435,9 @@ var controls_generate = [
|
|||
{view: "search", id: "search_product_id",
|
||||
name: "search_product_id", label: "por Clave",
|
||||
labelPosition:'top', maxWidth:200,
|
||||
placeholder:'Captura la clave'},
|
||||
placeholder:'Presiona ENTER para buscar'},
|
||||
{view: "search", id: "search_product_name",
|
||||
name: "search_product_name", label: "por Descripción",
|
||||
name: "search_product_name", label: "por Descripción o Clave",
|
||||
labelPosition:'top', suggest: suggest_products,
|
||||
placeholder:'Captura al menos tres letras'},
|
||||
]},
|
||||
|
|
|
@ -11,7 +11,7 @@ var toolbar_products = [
|
|||
|
||||
|
||||
var grid_products_cols = [
|
||||
{ id: "id", header: "ID", width: 75},
|
||||
{ id: "id", header: "ID", width: 75, hidden: true},
|
||||
{ id: "clave", header: ["Clave", {content: "textFilter"}], width: 100,
|
||||
sort: 'string', footer: {content: 'rowCount', css: 'right'}},
|
||||
{ id: "descripcion", header: ["Descripción", {content: "textFilter"}],
|
||||
|
|
Loading…
Reference in New Issue