本文整理汇总了Python中webnotes.model.wrapper.getlist函数的典型用法代码示例。如果您正苦于以下问题:Python getlist函数的具体用法?Python getlist怎么用?Python getlist使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getlist函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_sal_slip
def create_sal_slip(self):
"""
Creates salary slip for selected employees if already not created
"""
emp_list = self.get_emp_list()
ss_list = []
for emp in emp_list:
if not sql("""select name from `tabSalary Slip`
where docstatus!= 2 and employee = %s and month = %s and fiscal_year = %s and company = %s
""", (emp[0], self.doc.month, self.doc.fiscal_year, self.doc.company)):
ss = Document('Salary Slip')
ss.fiscal_year = self.doc.fiscal_year
ss.employee = emp[0]
ss.month = self.doc.month
ss.email_check = self.doc.send_email
ss.company = self.doc.company
ss.save(1)
ss_obj = get_obj('Salary Slip', ss.name, with_children=1)
ss_obj.get_emp_and_leave_details()
ss_obj.calculate_net_pay()
ss_obj.validate()
ss_obj.doc.save()
for d in getlist(ss_obj.doclist, 'earning_details'):
d.save()
for d in getlist(ss_obj.doclist, 'deduction_details'):
d.save()
ss_list.append(ss.name)
return self.create_log(ss_list)
示例2: get_balance
def get_balance(self):
if not getlist(self.doclist,'entries'):
msgprint("Please enter atleast 1 entry in 'GL Entries' table")
else:
flag, self.doc.total_debit, self.doc.total_credit = 0,0,0
diff = flt(self.doc.difference)
# If any row without amount, set the diff on that row
for d in getlist(self.doclist,'entries'):
if (d.credit==0 or d.credit is None) and (d.debit==0 or d.debit is None) and (flt(diff) != 0):
if diff>0:
d.credit = flt(diff)
elif diff<0:
d.debit = flt(diff)
flag = 1
# Set the diff in a new row
if flag == 0 and (flt(diff) != 0):
jd = addchild(self.doc, 'entries', 'Journal Voucher Detail', self.doclist)
if diff>0:
jd.credit = flt(diff)
elif diff<0:
jd.debit = flt(diff)
# Set the total debit, total credit and difference
for d in getlist(self.doclist,'entries'):
self.doc.total_debit += flt(d.debit)
self.doc.total_credit += flt(d.credit)
self.doc.difference = flt(self.doc.total_debit) - flt(self.doc.total_credit)
示例3: get_allocated_sum
def get_allocated_sum(self,obj):
sum = 0
for d in getlist(obj.doclist,'sales_team'):
sum += flt(d.allocated_percentage)
if (flt(sum) != 100) and getlist(obj.doclist,'sales_team'):
msgprint("Total Allocated % of Sales Persons should be 100%")
raise Exception
示例4: on_submit
def on_submit(self):
if not getlist(self.doclist, 'maintenance_schedule_detail'):
msgprint("Please click on 'Generate Schedule' to get schedule")
raise Exception
self.check_serial_no_added()
self.validate_serial_no_warranty()
self.validate_schedule()
email_map ={}
for d in getlist(self.doclist, 'item_maintenance_detail'):
if d.serial_no:
self.update_amc_date(d.serial_no, d.end_date)
if d.incharge_name not in email_map:
e = sql("select email_id, name from `tabSales Person` where name='%s' " %(d.incharge_name),as_dict=1)[0]
email_map[d.incharge_name] = (e['email_id'])
scheduled_date =sql("select scheduled_date from `tabMaintenance Schedule Detail` \
where incharge_name='%s' and item_code='%s' and parent='%s' " %(d.incharge_name, \
d.item_code, self.doc.name), as_dict=1)
for key in scheduled_date:
if email_map[d.incharge_name]:
self.add_calender_event(key["scheduled_date"],email_map[d.incharge_name],d.item_code)
webnotes.conn.set(self.doc, 'status', 'Submitted')
示例5: cal_charges_and_item_tax_amt
def cal_charges_and_item_tax_amt(self):
""" Re-calculates other charges values and itemwise tax amount for getting valuation rate"""
import json
for pr in self.selected_pr:
obj = get_obj('Purchase Receipt', pr, with_children = 1)
total = 0
self.reset_other_charges(obj)
for prd in getlist(obj.doclist, 'purchase_receipt_details'):
prev_total, item_tax = flt(prd.amount), 0
total += flt(prd.qty) * flt(prd.purchase_rate)
try:
item_tax_rate = prd.item_tax_rate and json.loads(prd.item_tax_rate) or {}
except ValueError:
item_tax_rate = prd.item_tax_rate and eval(prd.item_tax_rate) or {}
ocd = getlist(obj.doclist, 'purchase_tax_details')
# calculate tax for other charges
for oc in range(len(ocd)):
# Get rate : consider if diff for this item
if item_tax_rate.get(ocd[oc].account_head) and ocd[oc].charge_type != 'Actual':
rate = item_tax_rate[ocd[oc].account_head]
else:
rate = flt(ocd[oc].rate)
tax_amount = self.cal_tax(ocd, prd, rate, obj.doc.net_total, oc)
total, prev_total, item_tax = self.add_deduct_taxes(ocd, oc, tax_amount, total, prev_total, item_tax)
prd.item_tax_amount = flt(item_tax)
prd.save()
obj.doc.save()
示例6: validate_reference_value
def validate_reference_value(self, obj, to_docname):
""" Check consistency of value with reference document"""
for t in getlist(self.doclist, 'table_mapper_details'):
# Reference key is the fieldname which will relate to the from_table
if t.reference_doctype_key:
for d in getlist(obj.doclist, t.to_field):
if d.fields[t.reference_doctype_key] == self.doc.from_doctype:
self.check_consistency(obj.doc, d, to_docname)
self.check_ref_docstatus()
示例7: update_current_stock
def update_current_stock(self):
for d in getlist(self.doclist, 'delivery_note_details'):
bin = sql("select actual_qty from `tabBin` where item_code = %s and warehouse = %s", (d.item_code, d.warehouse), as_dict = 1)
d.actual_qty = bin and flt(bin[0]['actual_qty']) or 0
for d in getlist(self.doclist, 'packing_details'):
bin = sql("select actual_qty, projected_qty from `tabBin` where item_code = %s and warehouse = %s", (d.item_code, d.warehouse), as_dict = 1)
d.actual_qty = bin and flt(bin[0]['actual_qty']) or 0
d.projected_qty = bin and flt(bin[0]['projected_qty']) or 0
示例8: check_serial_no_added
def check_serial_no_added(self):
serial_present =[]
for d in getlist(self.doclist, 'item_maintenance_detail'):
if d.serial_no:
serial_present.append(d.item_code)
for m in getlist(self.doclist, 'maintenance_schedule_detail'):
if serial_present:
if m.item_code in serial_present and not m.serial_no:
msgprint("Please click on 'Generate Schedule' to fetch serial no added for item "+m.item_code)
raise Exception
示例9: on_update
def on_update(self):
""" Update C-Form No on invoices"""
if len(getlist(self.doclist, 'invoice_details')):
inv = "'" + "', '".join([d.invoice_no for d in getlist(self.doclist, 'invoice_details')]) + "'"
sql("""update `tabSales Invoice` set c_form_no = '%s', modified ='%s'
where name in (%s)"""%(self.doc.name, self.doc.modified, inv))
sql("""update `tabSales Invoice` set c_form_no = '', modified = %s where name not
in (%s) and ifnull(c_form_no, '') = %s""", (self.doc.modified, self.doc.name, inv))
else:
msgprint("Please enter atleast 1 invoice in the table below", raise_exception=1)
self.calculate_total_invoiced_amount()
示例10: get_item_list
def get_item_list(self, obj, is_stopped=0):
"""get item list"""
il = []
for d in getlist(obj.doclist,obj.fname):
reserved_wh, reserved_qty = '', 0 # used for delivery note
qty = flt(d.qty)
if is_stopped:
qty = flt(d.qty) > flt(d.delivered_qty) and flt(flt(d.qty) - flt(d.delivered_qty)) or 0
if d.prevdoc_doctype == 'Sales Order':
# used in delivery note to reduce reserved_qty
# Eg.: if SO qty is 10 and there is tolerance of 20%, then it will allow DN of 12.
# But in this case reserved qty should only be reduced by 10 and not 12.
tot_qty, max_qty, tot_amt, max_amt, reserved_wh = self.get_curr_and_ref_doc_details(d.doctype, 'prevdoc_detail_docname', d.prevdoc_detail_docname, obj.doc.name, obj.doc.doctype)
if((flt(tot_qty) + flt(qty) > flt(max_qty))):
reserved_qty = -(flt(max_qty)-flt(tot_qty))
else:
reserved_qty = - flt(qty)
if obj.doc.doctype == 'Sales Order':
reserved_wh = d.reserved_warehouse
if self.has_sales_bom(d.item_code):
for p in getlist(obj.doclist, 'packing_details'):
if p.parent_detail_docname == d.name and p.parent_item == d.item_code:
# the packing details table's qty is already multiplied with parent's qty
il.append({
'warehouse': p.warehouse,
'reserved_warehouse': reserved_wh,
'item_code': p.item_code,
'qty': flt(p.qty),
'reserved_qty': (flt(p.qty)/qty)*(reserved_qty),
'uom': p.uom,
'batch_no': p.batch_no,
'serial_no': p.serial_no,
'name': d.name
})
else:
il.append({
'warehouse': d.warehouse,
'reserved_warehouse': reserved_wh,
'item_code': d.item_code,
'qty': qty,
'reserved_qty': reserved_qty,
'uom': d.stock_uom,
'batch_no': d.batch_no,
'serial_no': d.serial_no,
'name': d.name
})
return il
示例11: make_gl_entries
def make_gl_entries(self, doc, doclist, cancel=0, adv_adj = 0, use_mapper='', merge_entries = 1, update_outstanding='Yes'):
self.entries = []
# get entries
le_map_list = webnotes.conn.sql("select * from `tabGL Mapper Detail` where parent = %s", use_mapper or doc.doctype, as_dict=1)
self.td, self.tc = 0.0, 0.0
for le_map in le_map_list:
if le_map['table_field']:
for d in getlist(doclist,le_map['table_field']):
# purchase_tax_details is the table of other charges in purchase cycle
if le_map['table_field'] != 'purchase_tax_details' or (le_map['table_field'] == 'purchase_tax_details' and d.fields.get('category') != 'Valuation'):
self.make_single_entry(doc,d,le_map,cancel, merge_entries)
else:
self.make_single_entry(None,doc,le_map,cancel, merge_entries)
# save entries
self.save_entries(cancel, adv_adj, update_outstanding)
# check total debit / credit
# Due to old wrong entries (total debit != total credit) some voucher could be cancelled
if abs(self.td - self.tc) > 0.01 and not cancel:
msgprint("Debit and Credit not equal for this voucher: Diff (Debit) is %s" % (self.td-self.tc))
raise Exception
# set as cancelled
if cancel:
vt = self.get_val(le_map['voucher_type'], doc, doc)
vn = self.get_val(le_map['voucher_no'], doc, doc)
webnotes.conn.sql("update `tabGL Entry` set is_cancelled='Yes' where voucher_type=%s and voucher_no=%s", (vt, vn))
示例12: pr_required
def pr_required(self):
res = sql("select value from `tabSingles` where doctype = 'Global Defaults' and field = 'pr_required'")
if res and res[0][0] == 'Yes':
for d in getlist(self.doclist,'entries'):
if not d.purchase_receipt:
msgprint("Purchase Receipt No. required against item %s"%d.item_code)
raise Exception
示例13: create_remarks
def create_remarks(self):
r = []
if self.doc.cheque_no :
if self.doc.cheque_date:
r.append('Via Reference #%s dated %s' % (self.doc.cheque_no, formatdate(self.doc.cheque_date)))
else :
msgprint("Please enter Reference date")
raise Exception
for d in getlist(self.doclist, 'entries'):
if d.against_invoice and d.credit:
currency = sql("select currency from `tabSales Invoice` where name = '%s'" % d.against_invoice)
currency = currency and currency[0][0] or ''
r.append('%s %s against Invoice: %s' % (cstr(currency), fmt_money(flt(d.credit)), d.against_invoice))
if d.against_voucher and d.debit:
bill_no = sql("select bill_no, bill_date, currency from `tabPurchase Invoice` where name=%s", d.against_voucher)
if bill_no and bill_no[0][0] and bill_no[0][0].lower().strip() not in ['na', 'not applicable', 'none']:
bill_no = bill_no and bill_no[0]
r.append('%s %s against Bill %s dated %s' % (bill_no[2] and cstr(bill_no[2]) or '', fmt_money(flt(d.debit)), bill_no[0], bill_no[1] and formatdate(bill_no[1].strftime('%Y-%m-%d')) or ''))
if self.doc.user_remark:
r.append("User Remark : %s"%self.doc.user_remark)
if r:
self.doc.remark = ("\n").join(r)
示例14: validate_materials
def validate_materials(self):
""" Validate raw material entries """
check_list = []
for m in getlist(self.doclist, 'bom_materials'):
# check if operation no not in op table
if self.doc.with_operations and cstr(m.operation_no) not in self.op:
msgprint("""Operation no: %s against item: %s at row no: %s \
is not present at Operations table""" %
(m.operation_no, m.item_code, m.idx), raise_exception = 1)
item = self.get_item_det(m.item_code)
if item[0]['is_manufactured_item'] == 'Yes':
if not m.bom_no:
msgprint("Please enter BOM No aginst item: %s at row no: %s" %
(m.item_code, m.idx), raise_exception=1)
else:
self.validate_bom_no(m.item_code, m.bom_no, m.idx)
elif m.bom_no:
msgprint("""As Item %s is not a manufactured / sub-contracted item, \
you can not enter BOM against it (Row No: %s).""" %
(m.item_code, m.idx), raise_exception = 1)
if flt(m.qty) <= 0:
msgprint("Please enter qty against raw material: %s at row no: %s" %
(m.item_code, m.idx), raise_exception = 1)
self.check_if_item_repeated(m.item_code, m.operation_no, check_list)
示例15: update_packing_list_item
def update_packing_list_item(self,obj, packing_item_code, qty, warehouse, line):
bin = self.get_bin_qty(packing_item_code, warehouse)
item = self.get_packing_item_details(packing_item_code)
# check if exists
exists = 0
for d in getlist(obj.doclist, 'packing_details'):
if d.parent_item == line.item_code and d.item_code == packing_item_code and d.parent_detail_docname == line.name:
pi, exists = d, 1
break
if not exists:
pi = addchild(obj.doc, 'packing_details', 'Delivery Note Packing Item', 1, obj.doclist)
pi.parent_item = line.item_code
pi.item_code = packing_item_code
pi.item_name = item['item_name']
pi.parent_detail_docname = line.name
pi.description = item['description']
pi.uom = item['stock_uom']
pi.qty = flt(qty)
pi.actual_qty = bin and flt(bin['actual_qty']) or 0
pi.projected_qty = bin and flt(bin['projected_qty']) or 0
pi.prevdoc_doctype = line.prevdoc_doctype
if not pi.warehouse:
pi.warehouse = warehouse
if not pi.batch_no:
pi.batch_no = cstr(line.batch_no)
pi.idx = self.packing_list_idx
# saved, since this function is called on_update of delivery note
pi.save()
self.packing_list_idx += 1