forked from elmau/empresa-libre
Add wharehouse
This commit is contained in:
parent
2bfe86973a
commit
9fa35d5592
14
CHANGELOG.md
14
CHANGELOG.md
|
@ -1,7 +1,21 @@
|
||||||
v 1.43.0 [00-Jul-2021]
|
v 1.43.0 [00-Jul-2021]
|
||||||
----------------------
|
----------------------
|
||||||
- Soporte para entradas de almacen
|
- Soporte para entradas de almacen
|
||||||
|
- Soporte para m almacen
|
||||||
|
|
||||||
|
* IMPORTANTE:
|
||||||
|
|
||||||
|
Es necesario hacer una migració.
|
||||||
|
|
||||||
|
```
|
||||||
|
git pull origin master
|
||||||
|
|
||||||
|
cd source/app/models
|
||||||
|
|
||||||
|
python main.py -bk
|
||||||
|
|
||||||
|
python main.py -m -r RFC
|
||||||
|
```
|
||||||
|
|
||||||
v 1.42.1 [31-May-2021]
|
v 1.42.1 [31-May-2021]
|
||||||
----------------------
|
----------------------
|
||||||
|
|
|
@ -698,6 +698,23 @@ class AppInventoryEntries(object):
|
||||||
resp.status = falcon.HTTP_200
|
resp.status = falcon.HTTP_200
|
||||||
|
|
||||||
|
|
||||||
|
class AppWhareHouse(object):
|
||||||
|
|
||||||
|
def __init__(self, db):
|
||||||
|
self._db = db
|
||||||
|
|
||||||
|
def on_get(self, req, resp):
|
||||||
|
values = req.params
|
||||||
|
req.context['result'] = self._db.wharehouse_get(values)
|
||||||
|
resp.status = falcon.HTTP_200
|
||||||
|
|
||||||
|
def on_post(self, req, resp):
|
||||||
|
values = req.params
|
||||||
|
user = req.env['beaker.session']['userobj']
|
||||||
|
req.context['result'] = self._db.wharehouse_post(values, user)
|
||||||
|
resp.status = falcon.HTTP_200
|
||||||
|
|
||||||
|
|
||||||
class AppUsers(object):
|
class AppUsers(object):
|
||||||
|
|
||||||
def __init__(self, db):
|
def __init__(self, db):
|
||||||
|
|
|
@ -20,6 +20,7 @@ from controllers.main import (AppEmpresas,
|
||||||
AppSATFormaPago, AppSATLeyendaFiscales, AppCert, AppSucursales,
|
AppSATFormaPago, AppSATLeyendaFiscales, AppCert, AppSucursales,
|
||||||
AppPartnerProducts,
|
AppPartnerProducts,
|
||||||
AppInventoryEntries,
|
AppInventoryEntries,
|
||||||
|
AppWhareHouse,
|
||||||
AppUsers,
|
AppUsers,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -69,6 +70,7 @@ api.add_route('/cert', AppCert(db))
|
||||||
api.add_route('/sucursales', AppSucursales(db))
|
api.add_route('/sucursales', AppSucursales(db))
|
||||||
api.add_route('/partnerproducts', AppPartnerProducts(db))
|
api.add_route('/partnerproducts', AppPartnerProducts(db))
|
||||||
api.add_route('/inventoryentries', AppInventoryEntries(db))
|
api.add_route('/inventoryentries', AppInventoryEntries(db))
|
||||||
|
api.add_route('/wharehouse', AppWhareHouse(db))
|
||||||
api.add_route('/users', AppUsers(db))
|
api.add_route('/users', AppUsers(db))
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -487,6 +487,9 @@ class StorageEngine(object):
|
||||||
def inventory_entries_post(self, filters, user):
|
def inventory_entries_post(self, filters, user):
|
||||||
return main.InventoryEntries.post(filters, user)
|
return main.InventoryEntries.post(filters, user)
|
||||||
|
|
||||||
|
def wharehouse_post(self, values, user):
|
||||||
|
return main.Almacenes.post(values, user)
|
||||||
|
|
||||||
def users_get(self, filters, user):
|
def users_get(self, filters, user):
|
||||||
return main.Usuarios.get_data(filters, user)
|
return main.Usuarios.get_data(filters, user)
|
||||||
|
|
||||||
|
|
|
@ -3385,6 +3385,42 @@ class Almacenes(BaseModel):
|
||||||
class Meta:
|
class Meta:
|
||||||
order_by = ('name',)
|
order_by = ('name',)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def _get_all(cls):
|
||||||
|
rows = (Almacenes
|
||||||
|
.select(
|
||||||
|
Almacenes.id,
|
||||||
|
Almacenes.name,
|
||||||
|
)
|
||||||
|
.dicts()
|
||||||
|
)
|
||||||
|
return tuple(rows)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def _create(cls, args, user):
|
||||||
|
try:
|
||||||
|
obj, created = Almacenes.get_or_create(**args)
|
||||||
|
except Exception as e:
|
||||||
|
log.error(e)
|
||||||
|
msg = 'Ocurrio un error al agregar el almacen'
|
||||||
|
result = {'ok': False, 'msg': msg}
|
||||||
|
return result
|
||||||
|
|
||||||
|
if created:
|
||||||
|
rows = Almacenes._get_all()
|
||||||
|
result = {'ok': True, 'rows': rows}
|
||||||
|
else:
|
||||||
|
msg = 'El almacen ya existe'
|
||||||
|
result = {'ok': True, 'msg': msg}
|
||||||
|
|
||||||
|
return result
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def post(cls, values, user):
|
||||||
|
opt = values['opt']
|
||||||
|
args = utils.loads(values['values'])
|
||||||
|
return getattr(cls, f'_{opt}')(args, user)
|
||||||
|
|
||||||
|
|
||||||
class Sucursales(BaseModel):
|
class Sucursales(BaseModel):
|
||||||
wharehouse = ForeignKeyField(Almacenes, null=True)
|
wharehouse = ForeignKeyField(Almacenes, null=True)
|
||||||
|
|
|
@ -2994,3 +2994,33 @@ function cmd_add_wharehouse_click(){
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function add_wharehouse(name){
|
||||||
|
var grid = $$('grid_warehouse')
|
||||||
|
var data = {
|
||||||
|
opt: 'create',
|
||||||
|
values: {name: name},
|
||||||
|
}
|
||||||
|
|
||||||
|
webix.ajax().post('/wharehouse', data, {
|
||||||
|
error:function(text, data, XmlHttpRequest){
|
||||||
|
msg = 'Ocurrio un error, consulta a soporte técnico'
|
||||||
|
msg_error(msg)
|
||||||
|
},
|
||||||
|
success:function(text, data, XmlHttpRequest){
|
||||||
|
var values = data.json()
|
||||||
|
if(values.ok){
|
||||||
|
$$('txt_add_wharehouse').setValue('')
|
||||||
|
if(values.msg){
|
||||||
|
msg_ok(values.msg)
|
||||||
|
}else{
|
||||||
|
grid.parse(values.rows)
|
||||||
|
msg_ok('Almacen agregado correctamente')
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
msg_error(values.msg)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue