本文整理汇总了Python中utility.Utility.modelToDicts方法的典型用法代码示例。如果您正苦于以下问题:Python Utility.modelToDicts方法的具体用法?Python Utility.modelToDicts怎么用?Python Utility.modelToDicts使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类utility.Utility
的用法示例。
在下文中一共展示了Utility.modelToDicts方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: dispatch
# 需要导入模块: from utility import Utility [as 别名]
# 或者: from utility.Utility import modelToDicts [as 别名]
def dispatch(request):
util = Utility(post=request.POST, get=request.GET)
c = util.nvlGet('c');
par = util.nvlGet('q', '')
if c is not None:
if 'formkonversi' == c:
return HttpResponse(json.dumps(prepareFormKonversi(util.data)))
if 'simpanitemkonversi' == c:
ipbl = simpanItemKonversi(util.data)
return HttpResponse(json.dumps(
util.modelToDicts([ipbl.barang, ipbl.konversi, ipbl], prefiks=['barang_', 'konversi_'])))
if 'hapusitemkonversi' == c:
iks = models.ItemKonversi.objects.filter(id__exact=util.nvlGet('itemId'))
for ik in iks:
jik = util.modelToDicts([ik])
ik.delete()
return HttpResponse(json.dumps(jik))
if 'getitemkonversi' == c:
ipbls = getItemKonversi(util.nvlGet('id', 0), util.nvlGet('kredebit'), util.nvlGet('jenisProduk', 1),
util.nvlGet('a', 20))
jitemkonversis = []
for ipbl in ipbls:
jitem = util.modelToDicts([ipbl.barang, ipbl],
replaces=['id:barang_id'])
jitemkonversis.append(jitem)
return HttpResponse(json.dumps(jitemkonversis))
if 'gethdrkonversi' == c:
pbls = models.Konversi.objects.filter(id__exact=util.nvlGet('id', 0))
for pbl in pbls:
jpbl = util.modelToDicts([pbl])
return HttpResponse(json.dumps({'data': jpbl}))
return HttpResponse('No data with this id ')
if 'gettotalitemkonversi' == c:
y = 'nanti di garap'
if 'formbrowsekonversi' == c:
return render_to_response('inventory/form_konversi_browse.html')
if 'browsekonversi' == c:
return HttpResponse(json.dumps({'data': browseKonversi(util.data)}))
if 'simpankonversi' == c:
bb = barangBisnis()
konversi_id = util.nvlGet('id', 0)
html = '''
<div class="formrow" style:font 12px verdana>Data rencana konversi telah berhasil disimpang</div>
<input type="button" value="Lanjut Perekaman" id="btnMore"/>
'''
if konversi_id != 0:
bb.konversiProduksi(konversi_id)
return HttpResponse(
json.dumps({'sukses': True, 'message': 'Berhasil melakukan konversi', 'html': html}))
else: return HttpResponse(json.dumps({'sukses': False, 'message': 'Rencana konversi tidak disimpan'}))
if 'konversisider' == c:
return HttpResponse(json.dumps({'html': getKonversiSider(util.data)}))
return HttpResponseServerError('can''t find param')
示例2: getMaping
# 需要导入模块: from utility import Utility [as 别名]
# 或者: from utility.Utility import modelToDicts [as 别名]
def getMaping(id):
util = Utility()
items = models.ItemBcdtMap.objects.filter(bcdt__id__exact=id)
jitems = [];
for item in items:
if item.barang is not None:
jitem = util.modelToDicts([item.barang, item],
replaces=['id:barang_id', 'nama:barang_nama', 'merk:barang_merk'])
else:
jitem = util.modelToDicts([item.barang, item])
jitems.append(jitem)
return jitems
示例3: dispatch
# 需要导入模块: from utility import Utility [as 别名]
# 或者: from utility.Utility import modelToDicts [as 别名]
def dispatch(request):
util = Utility(post=request.POST, get=request.GET)
c = util.nvlGet('c');
par = util.nvlGet('q', '')
if c is not None:
if 'formpembelian' == c:
return HttpResponse(json.dumps(prepareFormBarang(util.data)))
if 'formrencanapembelian' == c:
return HttpResponse(json.dumps(prepareFormRencanaPembelian(util.data)))
if 'simpanitempembelian' == c:
ipbl = simpanItemPembelian(util.data)
return HttpResponse(json.dumps(
util.modelToDicts([ipbl.barang, ipbl.pembelian, ipbl.pembelian.supplier, ipbl],
replaces=['id:barang_id', 'id:id', 'id:supplier_id', 'id:id', 'id:itempembelian_id',
'tanggal:tgl_rencana_pembelian', 'nomor:no_rencana_pembelian'])))
if 'getitempembelian' == c:
ipbls = getItemPembelian(util.nvlGet('id', 0), util.nvlGet('a', 20))
jitempembelians = []
for ipbl in ipbls:
jitem = util.modelToDicts([ipbl.barang, ipbl],
replaces=['id:barang_id'])
jitempembelians.append(jitem)
return HttpResponse(json.dumps(jitempembelians))
if 'gethdrpembelian' == c:
pbls = models.Pembelian.objects.filter(id__exact=util.nvlGet('id', 0))
for pbl in pbls:
jpbl = util.modelToDicts([pbl.supplier, pbl], prefiks=['supplier', ''])
return HttpResponse(json.dumps({'data': jpbl}))
if 'gettotalitempembelian' == c:
y = 'nanti di garap'
if 'formbrowsepembelian' == c:
return render_to_response('inventory/form_pembelian_browse.html')
if 'browsepembelian' == c:
return HttpResponse(json.dumps({'data': browsePembelian(util.data)}))
if 'simpanrencanapembelian' == c:
bb = barangBisnis()
pembelian_id = util.nvlGet('id', 0)
html = '''
<div class="formrow" style:font 12px verdana>Data rencana pembelian telah berhasil disimpang</div>
<input type="button" value="Lanjut Perekaman" id="btnMore"/>
'''
if pembelian_id != 0:
bb.debetPembelian(pembelian_id)
return HttpResponse(
json.dumps({'sukses': True, 'message': 'Berhasil melakukan pembelian', 'html': html}))
else: return HttpResponse(json.dumps({'sukses': False, 'message': 'Rencana pembelian tidak disimpan'}))
if 'pembeliansider' == c:
return HttpResponse(json.dumps({'html': getPembelianSider(util.data)}))
return HttpResponseServerError('can''t find param')
示例4: getMutasiSider
# 需要导入模块: from utility import Utility [as 别名]
# 或者: from utility.Utility import modelToDicts [as 别名]
def getMutasiSider(reqData):
requtil = Utility(reqData=reqData)
pas = models.Mutasi.objects.filter(id__exact=requtil.nvlGet('id'))
if pas[0] is not None:
jpas = requtil.modelToDicts([pas[0].supplier, pas[0]])
items = models.ItemMutasi.objects.filter(mutasi__id__exact=pas[0].id)
jitems = []
jitem = {};
if items[0] is not None:
for item in items:
jitem = requtil.modelToDicts([item.barang, item])
jitems.append(jitem)
jpas.update({'items': jitems})
html = render_to_string('inventory/form_mutasi_sider.html', jpas)
return html
示例5: lookupBarang
# 需要导入模块: from utility import Utility [as 别名]
# 或者: from utility.Utility import modelToDicts [as 别名]
def lookupBarang(katakunci, id, max):
requtil = Utility()
if max is None:
max = 40;
pasiens = []
if katakunci is not None and '' != katakunci and id is None:
print 'katakunci'
print max
pasiens = models.Barang.objects.filter(
Q(nama__icontains=katakunci) | Q(merk__icontains=katakunci) | Q(kode__icontains=katakunci))[
:max]
elif id is not None:
print 'id'
pasiens = models.Barang.objects.filter(id__exact=id)
print 'query from id'
#lookup specific id, to set id value
else:
print 'other'
print id
print katakunci
pasiens = models.Barang.objects.all()[:max]
jpasiens = [];
for pasien in pasiens:
jpasien = requtil.modelToDicts([pasien])
jpasiens.append(jpasien)
return jpasiens;
示例6: lookupBdi
# 需要导入模块: from utility import Utility [as 别名]
# 或者: from utility.Utility import modelToDicts [as 别名]
def lookupBdi(katakunci, inventory_id, id, max):
requtil = Utility()
if max is None:
max = 40;
pasiens = []
if katakunci is not None and '' != katakunci and id is None:
print 'katakunci'
print max
pasiens = models.BarangDiInventory.objects.filter(
Q(barang__nama__icontains=katakunci) | Q(barang__merk__icontains=katakunci) |
Q(barang__kode__icontains=katakunci, inventori__id__exact=inventory_id))[
:max]
elif id is not None:
print 'id'
pasiens = models.BarangDiInventory.objects.filter(barang__id__exact=id)
print 'query from id'
#lookup specific id, to set id value
else:
print 'other'
print id
print katakunci
pasiens = models.BarangDiInventory.objects.filter(inventory__id__exact=inventory_id)[:max]
jpasiens = [];
for bdi in pasiens:
jpasien = requtil.modelToDicts([bdi.barang])
jpasiens.append(jpasien)
return jpasiens;
示例7: saveUpdateBarangDiInventory
# 需要导入模块: from utility import Utility [as 别名]
# 或者: from utility.Utility import modelToDicts [as 别名]
def saveUpdateBarangDiInventory(reqData):
requtil = Utility(reqData=reqData)
if requtil.nvlGet('id', None) is None:
#barang baru di inventory
#init barang di inventory object
bdi = models.BarangDiInventory()
#init barang object
brg = models.Barang()
brg = requtil.bindRequestModel(brg)
brg.save()
#safe harga
hrg = models.Harga();
hrg = requtil.bindRequestModel(hrg)
hrg.awal = date.today();
hrg.barang = brg;
hrg.keterangan = 'initial value'
hrg.save()
#set default inventory to main ware house in case it doesn't exists;
inventory_id = requtil.nvlGet('inventory_id', settings.MAIN_WAREHOUSE)
#check the inventory entry
inv = models.Inventory.objects.filter(id__exact=inventory_id)
#the inventory will be defined by reference later
if inv is not None and len(inv) > 0:
bdi.inventory = inv[0]
bdi.barang = brg
bdi.saldo = 0
bdi.save()
return requtil.modelToDicts([inv, hrg, brg, bdi])
示例8: dispatch
# 需要导入模块: from utility import Utility [as 别名]
# 或者: from utility.Utility import modelToDicts [as 别名]
def dispatch(request):
util = Utility(post=request.POST, get=request.GET)
c = util.nvlGet('c');
par = util.nvlGet('q', '')
if c is not None:
if 'formpartner' == c:
return HttpResponse(json.dumps(prepareFormPartner(util.data)))
if 'formpencarianpartner' == c:
return render_to_response('inventory/form_partner_browse.html')
if 'pencarianpartner' == c:
return HttpResponse(json.dumps({'data': pencarianPartner(util.data)}))
if 'partnersider' == c:
return HttpResponse(json.dumps({'html': getPartnerSider(util.data)}))
if 'caripartner' == c:
return render_to_response('inventory/cari_kata_kunci.html')
if 'lookuppartner' == c:
return HttpResponse(json.dumps(
lookupPartner(util.nvlGet('katakunci', None), util.nvlGet('id', None), util.nvlGet('max', None))));
if 'formlistpartner' == c:
return HttpResponse(json.dumps(dict(
{'html': render_to_string('inventory/list_partner.html'),
'data': prepareListPartnerByKataKunci(util.data)})))
if 'partnerbyname' == c:
par = util.nvlGet('q', '')
namas = []
#g=500/0
nama = 'noname'
if len(par) > 2:
pas = models.Partner.objects.filter(nama__icontains=par)[:util.nvlGet('a', 8)]
for p in pas:
nama = util.modelToDicts([p])
namas.append(nama)
#return HttpResponseServerError('error dari server lhoo')
data = dict({'eventid': util.nvlGet('eventid'), 'data': namas})
return HttpResponse(json.dumps(data))
if 'partnerbyid' == c:
cuss = models.Partner.objects.filter(id__exact=par)
for cus in cuss:
return HttpResponse(json.dumps(util.modelToDict(cus)))
return HttpResponse({'message': 'no partner'})
if 'partner_bynamalamat' == c:
jresp = dict({'data': prepareListPartnerByKataKunci(util.data), 'eventid': util.nvlGet('eventid')})
return HttpResponse(json.dumps(jresp))
if 'hapuspartner' == c:
custs = models.Supplier.objects.filter(id__exact=util.nvlGet('id', 0));
dp = {}
if custs:
#hapus semua barang di inventory
dp = util.modelToDict(custs[0])
custs[0].delete()
return HttpResponse(json.dumps(dp))
if 'updatesupplier' == c:
#hanya untuk mengupdate data barang, bukan barang di inventory
return HttpResponse(json.dumps(saveUpdatePartner(util.data)))
if 'simpanpartner' == c:
#simpanPasien(request.POST)
return HttpResponse(json.dumps(saveUpdatePartner(util.data)))
return HttpResponseServerError('can''t find param')
示例9: getSupplierSider
# 需要导入模块: from utility import Utility [as 别名]
# 或者: from utility.Utility import modelToDicts [as 别名]
def getSupplierSider(reqData):
requtil = Utility(reqData=reqData)
pas = models.Supplier.objects.filter(id__exact=requtil.nvlGet('id'))
if pas[0] is not None:
id = pas[0].id
jpas = requtil.modelToDicts([pas[0]])
html = render_to_string('inventory/form_supplier_sider.html', jpas)
return html
示例10: getBarangSider
# 需要导入模块: from utility import Utility [as 别名]
# 或者: from utility.Utility import modelToDicts [as 别名]
def getBarangSider(reqData):
requtil = Utility(reqData=reqData)
pas = models.Barang.objects.filter(id__exact=requtil.nvlGet('id'))
if pas[0] is not None:
id = pas[0].id
jpas = requtil.modelToDicts([pas[0]])
urlss = "000000%s.jpg" % (id)
jpas['url'] = urlss[-10:]
html = render_to_string('inventory/form_barang_sider.html', jpas)
return html
示例11: prepareFormSupplier
# 需要导入模块: from utility import Utility [as 别名]
# 或者: from utility.Utility import modelToDicts [as 别名]
def prepareFormSupplier(reqData):
requtil = Utility(reqData=reqData)
jresp = dict({'html': render_to_string('inventory/form_supplier.html', {})})
data = {}
if 'id' in reqData:
id = requtil.nvlGet('id')
if id > 0:
sup = models.Supplier.objects.get(id__exact=requtil.nvlGet('id'))
data = requtil.modelToDicts([sup])
jresp.update({'data': data});
return jresp
示例12: prepareFormBarang
# 需要导入模块: from utility import Utility [as 别名]
# 或者: from utility.Utility import modelToDicts [as 别名]
def prepareFormBarang(reqData):
requtil = Utility(reqData=reqData)
jresp = dict({'html': render_to_string('inventory/form_mutasi.html', {})})
data = {}
if 'id' in reqData:
id = requtil.nvlGet('id')
if id > 0:
brg = models.Barang.objects.get(id__exact=requtil.nvlGet('id'))
data = requtil.modelToDicts([brg])
jresp.update({'data': data});
return jresp
示例13: prepareFormRencanaPembelian
# 需要导入模块: from utility import Utility [as 别名]
# 或者: from utility.Utility import modelToDicts [as 别名]
def prepareFormRencanaPembelian(reqData):
requtil = Utility(reqData=reqData)
jresp = dict({'html': render_to_string('inventory/form_rencana_pembelian.html', {})})
data = {}
if 'id' in reqData:
id = requtil.nvlGet('id')
if id > 0:
cust = models.Customer.objects.get(id__exact=requtil.nvlGet('id'))
data = requtil.modelToDicts([cust])
jresp.update({'data': data});
return jresp
示例14: saveUpdateSupplier
# 需要导入模块: from utility import Utility [as 别名]
# 或者: from utility.Utility import modelToDicts [as 别名]
def saveUpdateSupplier(reqData):
requtil = Utility(reqData=reqData)
sup = models.Supplier()
sup = requtil.bindRequestModel(sup)
if requtil.nvlGet('id', None) is None:
#barang baru di inventory
#init barang di inventory object
#init barang object
sup.save()
else: sup.save()
return requtil.modelToDicts([sup])
示例15: saveUpdatePartner
# 需要导入模块: from utility import Utility [as 别名]
# 或者: from utility.Utility import modelToDicts [as 别名]
def saveUpdatePartner(reqData):
requtil = Utility(reqData=reqData)
cust = models.Partner()
#init barang object
cust = requtil.bindRequestModel(cust)
if requtil.nvlGet('id', None) is None:
#barang baru di inventory
#init barang di inventory object
cust.save()
else: cust.save()
return requtil.modelToDicts([cust])