Get exists by warehouse
This commit is contained in:
parent
2055a904f6
commit
f792b79655
|
@ -715,6 +715,17 @@ class AppWareHouse(object):
|
|||
resp.status = falcon.HTTP_200
|
||||
|
||||
|
||||
class AppWareHouseProduct(object):
|
||||
|
||||
def __init__(self, db):
|
||||
self._db = db
|
||||
|
||||
def on_get(self, req, resp):
|
||||
values = req.params
|
||||
req.context['result'] = self._db.warehouseproduct_get(values)
|
||||
resp.status = falcon.HTTP_200
|
||||
|
||||
|
||||
class AppUsers(object):
|
||||
|
||||
def __init__(self, db):
|
||||
|
|
|
@ -21,6 +21,7 @@ from controllers.main import (AppEmpresas,
|
|||
AppPartnerProducts,
|
||||
AppInventoryEntries,
|
||||
AppWareHouse,
|
||||
AppWareHouseProduct,
|
||||
AppUsers,
|
||||
)
|
||||
|
||||
|
@ -71,6 +72,7 @@ api.add_route('/sucursales', AppSucursales(db))
|
|||
api.add_route('/partnerproducts', AppPartnerProducts(db))
|
||||
api.add_route('/inventoryentries', AppInventoryEntries(db))
|
||||
api.add_route('/warehouse', AppWareHouse(db))
|
||||
api.add_route('/warehouseproduct', AppWareHouseProduct(db))
|
||||
api.add_route('/users', AppUsers(db))
|
||||
|
||||
|
||||
|
|
|
@ -493,6 +493,9 @@ class StorageEngine(object):
|
|||
def warehouse_post(self, values, user):
|
||||
return main.Almacenes.post(values, user)
|
||||
|
||||
def warehouseproduct_get(self, filters):
|
||||
return main.WareHouseProduct.get_data(filters)
|
||||
|
||||
def users_get(self, filters, user):
|
||||
return main.Usuarios.get_data(filters, user)
|
||||
|
||||
|
|
|
@ -4049,6 +4049,29 @@ class WareHouseProduct(BaseModel):
|
|||
(('warehouse', 'product'), True),
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def _get_by_product(cls, args):
|
||||
id = int(args['id'])
|
||||
select = (
|
||||
WareHouseProduct.id,
|
||||
Almacenes.name.alias('warehouse'),
|
||||
WareHouseProduct.exists,
|
||||
)
|
||||
where = (WareHouseProduct.product==id)
|
||||
rows = (WareHouseProduct
|
||||
.select(*select)
|
||||
.join(Almacenes)
|
||||
.switch(WareHouseProduct)
|
||||
.where(where)
|
||||
.dicts()
|
||||
)
|
||||
return tuple(rows)
|
||||
|
||||
@classmethod
|
||||
def get_data(cls, values):
|
||||
opt = values.pop('opt')
|
||||
return getattr(cls, f'_get_{opt}')(values)
|
||||
|
||||
@classmethod
|
||||
def update_exists(cls, args):
|
||||
if args['storage'] is None:
|
||||
|
|
|
@ -476,8 +476,8 @@ function cmd_show_exists_click(id, e, node){
|
|||
msg_error('Selecciona un Producto')
|
||||
return
|
||||
}
|
||||
|
||||
win_show_exists.init()
|
||||
$$('grid_warehouse_exists').load('warehouseproduct?opt=by_product&id='+row.id)
|
||||
$$('win_show_exists').show()
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue