def editstore(id): """ Редактирование позицию на складе """ modstore = ModStore() mod = ModGroupStore() form = StoreIncomingForm() data = modstore.viewStoreIncomingId(id) # grprod_id = viewGroupProduct(data.gid) grprod_id = mod.show(data.gid) # allgrprod = allGroupProduct() allgrprod = mod.all() if request.method == 'POST' and form.validate(): add = [] for i in form: if i.data != None: add.append((i.name, i.data)) add.append(('gid', request.form['gid'])) update = dict(add) print('==UPDATE=StoreIncoming==' * 3) print(update) update['total_sum'] = float(update['quantity']) * float( update['quantity_sum']) del update['csrf_token'] edit = modstor.editStoreIncomingId(id, **update) if add == 'error': error = 'Ошибка' return render_template('store/incoming/edit.html', form=form, error=error) else: return redirect('core/store/all') return render_template('store/incoming/edit.html', form=form, data=data, allgrprod=allgrprod, grprod=grprod_id)
def addstore(): """Приход на склад """ date_today = date.today().strftime('%Y-%m-%d') form = StoreIncomingForm(request.form) mod = ModGroupStore() modstore = ModStore() allgrprod = mod.all() data = {} data['allgrprod'] = allgrprod gid = request.args.get('g') listGroupID = modstore.listStoreIncomingGID(gid) print('-FORM-' * 10) print(request.args) print(request.form) addIncomItemId = list(request.form.to_dict()) print(addIncomItemId) data['listGroupID'] = listGroupID data['incomings'] = addIncomItemId if request.method == 'POST': materials = request.form.to_dict() print('-=-materials===' * 8) print(materials) ListAddItemsId = ModStore.additems(**materials) # data['ListAddItemsId'] = ListAddItemsId data['ListAddItemsId'] = [ modstore.viewStoreIncomingId(int(i)) for i in ListAddItemsId ] return render_template('store/incoming/add.html', form=form, data=data, date_today=date_today) return render_template('store/incoming/add.html', form=form, data=data, date_today=date_today)
def allstore(): """Список всех позиций на складе """ modstore = ModStore() data = modstore.all() # data = allStore() # allgrprod = allGroupProduct() mod = ModGroupStore() allgrprod = mod.all() if request.method == 'POST': id = request.form['gid'] return redirect('core/store/list/' + id) return render_template('store/all.html', data=data, allgrprod=allgrprod)
def addgroupsstore(): """Добавить группу наименований на складе""" form = GroupProductForm(request.form) if request.method == 'POST' and form.validate(): add = [] for i in form: if i.data != None: add.append((i.name, i.data)) add_data = dict(add) mod = ModGroupStore() mod.add(name=add_data.get('name'), descr=add_data.get('descr')) return redirect('core/store/all') return render_template('store/groups/add.html', form=form)
def addlistitems(gid): """Выборка с группы наименования """ modstore = ModStore() date_today = date.today().strftime('%Y-%m-%d') form = StoreIncomingForm(request.form) data = modstore.listStoreIncomingGID(gid) mod = ModGroupStore() allgrprod = mod.all() listGroupID = modstore.listStoreIncomingGID(gid) addIncomItemId = list(request.form.to_dict()) data = {} data['gid'] = gid data['allgrprod'] = allgrprod data['listGroupID'] = listGroupID data['incomings'] = addIncomItemId data['ListAddItemsId'] = [] materials = request.form.to_dict() if request.method == 'POST': del_item_id = [k for k, v in materials.items() if v == 'del'] if del_item_id: item_id = str(del_item_id[0][8:]) del materials[del_item_id[0]] del materials['Incoming' + str(item_id)] # save_items = request.form.get('save_items') save_item = [k for k, v in materials.items() if v == 'Записать'] print(save_item) if save_item: save_item_id = str(save_item[0][13:]) save = [(k, v) for k, v in materials.items() if k[:4] == 'Inc' + save_item_id] print(save) ListAddItemsId = ModStore.additems(**materials) print('------ListAddItemsId-----' * 5) print(ListAddItemsId) print(request.form.to_dict()) print('-FORM-' * 10) print(request.form) data['ListAddItemsId'] = [ modstore.viewStoreIncomingId(int(i)) for i in ListAddItemsId ] return render_template('store/incoming/add.html', form=form, data=data, date_today=date_today) return render_template('store/incoming/add.html', form=form, data=data, date_today=date_today)
def addexpensestore(order_id): """ Создание расходной накладной """ date_today = date.today().strftime('%Y-%m-%d') form = StoreIncomingForm() modstore = ModStore() mod = ModGroupStore() allgrprod = mod.all() allstore = modstore.allStoreIncoming() data = {} data['order_id'] = order_id data['allgrprod'] = allgrprod data['allstore'] = allstore if request.method == 'POST': materials = request.form.to_dict() cancel = [] send_expense = [] for key, val in materials.items(): if key[0:3] == '000': cancel.append(key) cancel.append(str(int(key))) else: if key[0:3] == '001': send_expense.append(key) for i in cancel: print('---i===' * 8) print(i) if i: del materials[i] materials = [(int(key), val) for key, val in materials.items()] data['materials'] = set(materials) if send_expense: if send_expense[0] == '001': print('send_expense---' * 3) print(data['materials']) print(send_expense) data = data['materials'] # add = addExpense() return redirect('core/orders/addtype/' + str(order_id)) return render_template('store/expense.html', form=form, data=data, date_today=date_today) return render_template('store/expense.html', form=form, data=data, date_today=date_today)
def incoming_list(): """Просмотр всех наименований на склад""" data = modstore.allStoreIncoming() # allgrprod = allGroupProduct() mod = ModGroupStore() allgrprod = mod.all() day = {} day['dmyw'] = date.today().strftime('01-%m-%Y') day['dmyf'] = date.today().strftime('%d-%m-%Y') if request.method == 'POST': id = request.form['gid'] return redirect('core/store/list/' + id) return render_template('store/incoming/list.html', data=data, allgrprod=allgrprod, day=day)
def liststore(gid): """ Просмотр группы на складе """ modstore = ModStore() mod = ModGroupStore() allgrprod = mod.all() grprod_id = mod.show(gid) data = modstore.viewStoreIncomingId(gid) gid_list = modstore.listStoreIncomingGID(gid) # allgrprod = allGroupProduct() if request.method == 'POST': gid = request.form['gid'] if gid: return redirect('core/store/list/' + gid) else: return redirect('core/store/all') return render_template('store/list.html', data=data, allgrprod=allgrprod, grprod=grprod_id, gidlist=gid_list)