本文整理汇总了Python中webnotes.model.doclist.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: update_warranty_amc_history
def update_warranty_amc_history(self, submit = 1):
if submit:
for d in getlist(self.doclist, 'delivery_note_details'):
if d.serial_no:
serial_nos = self.get_sr_no_list(d.serial_no)
for s in serial_nos:
sr = Document('Serial No', s)
child = addchild(sr, 'warranty_amc_history', 'Warranty AMC History', 0)
child.from_date = self.doc.transaction_date
child.to_date = d.warranty_expiry_date
child.status = 'Under Warranty'
child.against_doctype = self.doc.doctype
child.against_docname = self.doc.name
child.customer = self.doc.customer
child.territory = self.doc.territory
child.save()
sr.warranty_amc_status = 'Under Warranty'
sr.warranty_expiry_date = d.warranty_expiry_date
sr.save()
else:
sql("delete from `tabWarranty AMC History` where against_doctype = %s and against_docname = %s", (self.doc.doctype, self.doc.name))
sr_list = []
for d in getlist(self.doclist, 'service_order_details'):
if d.serial_no:
serial_nos = self.get_sr_no_list(d.serial_no)
for s in serial_nos:
sql("update `tabSerial No` set warranty_expiry_date = '' where name = '%s'" % (s))
sr_list.append(s)
self.update_serial_no_warranty_amc_status(serial_no_list = sr_list)
示例3: calc_pr_other_charges
def calc_pr_other_charges(self, name):
# re-calculate other charges
obj = get_obj('Purchase Receipt', name, with_children = 1)
total = 0
net_total = obj.doc.net_total
for prd in getlist(obj.doclist, 'purchase_receipt_details'):
prev_total, item_tax = flt(prd.amount), 0
total += flt(flt(prd.qty) * flt(prd.purchase_rate))
check_tax = 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)):
if check_tax.get(ocd[oc].account_head) and ocd[oc].charge_type != 'Actual':
rate = check_tax[ocd[oc].account_head]
else:
rate = flt(ocd[oc].rate)
tax_amount = self.cal_tax(ocd, prd, rate, net_total, oc)
if ocd[oc].add_deduct_tax == 'Add':
add_deduct_taxes(self, ocd, oc, tax_amount, total_amount, total, prev_total, f=1)
elif ocd[oc].add_deduct_tax == 'Deduct':
add_deduct_taxes(self, ocd, oc, tax_amount, total_amount, total, prev_total, f=-1)
prd.item_tax_amount = flt(item_tax)
prd.save()
obj.doc.save()
示例4: get_against_account
def get_against_account(self):
# Debit = Credit
debit, credit = 0.0, 0.0
debit_list, credit_list = [], []
for d in getlist(self.doclist, "entries"):
debit += flt(d.debit)
credit += flt(d.credit)
if flt(d.debit) > 0 and (d.account not in debit_list):
debit_list.append(d.account)
if flt(d.credit) > 0 and (d.account not in credit_list):
credit_list.append(d.account)
self.doc.total_debit = debit
if self.doc.tds_applicable == "Yes":
self.doc.total_credit = credit + flt(self.doc.ded_amount)
else:
self.doc.total_credit = credit
if abs(self.doc.total_debit - self.doc.total_credit) > 0.001:
msgprint(
"Debit must be equal to Credit. The difference is %s" % (self.doc.total_debit - self.doc.total_credit)
)
raise Exception
# update against account
for d in getlist(self.doclist, "entries"):
if flt(d.debit) > 0:
d.against_account = ", ".join(credit_list)
if flt(d.credit) > 0:
d.against_account = ", ".join(debit_list)
示例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: update_warranty_amc_history
def update_warranty_amc_history(self, submit=1):
if self.doc.order_type in ["AMC", "OTS (One Time Service)"]:
sr_list = []
if submit:
for d in getlist(self.doclist, "service_order_details"):
sr = Document("Serial No", d.serial_no)
child = addchild(sr, "warranty_amc_history", "Warranty AMC History", 0)
child.from_date = d.start_date
child.to_date = d.end_date
child.status = (self.doc.order_type == "AMC") and "Under AMC" or "OTS (One Time Service)"
child.against_doctype = self.doc.doctype
child.against_docname = self.doc.name
child.customer = self.doc.customer
child.territory = self.doc.territory
child.save()
sr.warranty_amc_status = (self.doc.order_type == "AMC") and "Under AMC" or "OTS (One Time Service)"
sr.amc_expiry_date = d.end_date
sr.save()
sr_list.append(d.serial_no)
else:
sql(
"delete from `tabWarranty AMC History` where against_doctype = %s and against_docname = %s",
(self.doc.doctype, self.doc.name),
)
for d in getlist(self.doclist, "service_order_details"):
sql("update `tabSerial No` set amc_expiry_date = '' where name = '%s'" % (d.serial_no))
sr_list.append(d.serial_no)
self.update_serial_no_warranty_amc_status(serial_no_list=sr_list)
示例7: 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', 1, 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)
if self.doc.tds_applicable == 'Yes':
self.doc.total_credit = flt(self.doc.total_credit) + flt(self.doc.ded_amount)
self.doc.difference = flt(self.doc.total_debit) - flt(self.doc.total_credit)
示例8: get_item_list
def get_item_list(self, obj, is_stopped):
il = []
for d in getlist(obj.doclist,obj.fname):
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 = self.get_curr_and_ref_doc_details(d.doctype, 'prevdoc_detail_docname', d.prevdoc_detail_docname, 'Sales Order Item', 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)
warehouse = (obj.fname == "sales_order_details") and d.reserved_warehouse or d.warehouse
if self.has_sales_bom(d.item_code):
for p in getlist(obj.doclist, 'packing_details'):
#if p.parent_item == d.item_code: -- this fails when item with same name appears more than once in delivery note item table
if p.parent_detail_docname == d.name:
# the packing details table's qty is already multiplied with parent's qty
il.append([warehouse, p.item_code, flt(p.qty), (flt(p.qty)/qty)*(reserved_qty), p.uom, p.batch_no, p.serial_no])
else:
il.append([warehouse, d.item_code, qty, reserved_qty, d.stock_uom, d.batch_no, d.serial_no])
return il
示例9: sum_mod_val
def sum_mod_val(self):
count = count1 = count2 = 0.0
for e in getlist(self.doclist,'exe_declaration_details'):
count += flt(e.modified_amount1)
count = round(flt(self.doc.gross_income)) - count
for oi in getlist(self.doclist,'oth_inc_decl_details'):
count += flt(oi.modified_amount2)
for vi in getlist(self.doclist,'chap_via_decl_details'):
count2 += flt(vi.modified_amount3)
count = count - count2
for inv in getlist(self.doclist,'invest_80_decl_details'):
count1 += flt(inv.modified_amount4)
if(count1 >= 100000):
break
if(count1>100000):
count1=100000
count_lst = [count,count1]
return count_lst
示例10: quote_table
def quote_table(self):
if getlist(self.doclist, "enq_details"):
header_lbl = ["Item Code", "Item Name", "Description", "Reqd Qty", "UOM"]
item_tbl = """<table style="width:90%%; border:1px solid #AAA; border-collapse:collapse"><tr>"""
for i in header_lbl:
item_header = (
"""<td style="width=20%%; border:1px solid #AAA; border-collapse:collapse;"><b>%s</b></td>""" % i
)
item_tbl += item_header
item_tbl += """</tr>"""
for d in getlist(self.doclist, "enq_details"):
item_det = """
<tr><td style="width:20%%; border:1px solid #AAA; border-collpase:collapse">%s</td>
<td style="width:20%%; border:1px solid #AAA; border-collapse:collpase">%s</td>
<td style="width:20%%; border:1px solid #AAA; border-collapse:collpase">%s</td>
<td style="width:20%%; border:1px solid #AAA; border-collapse:collpase">%s</td>
<td style="width:20%%; border:1px solid #AAA; border-collapse:collpase">%s</td></tr>
""" % (
d.item_code,
d.item_name,
d.description,
d.reqd_qty,
d.uom,
)
item_tbl += item_det
item_tbl += """</table>"""
return item_tbl
示例11: update_warranty_amc_history
def update_warranty_amc_history(self, submit = 1):
if self.doc.order_type in ['AMC', 'OTS (One Time Service)']:
sr_list = []
if submit:
for d in getlist(self.doclist, 'service_order_details'):
sr = Document('Serial No', d.serial_no)
child = addchild(sr, 'warranty_amc_history', 'Warranty AMC History', 0)
child.from_date = d.start_date
child.to_date = d.end_date
child.status = (self.doc.order_type == 'AMC') and 'Under AMC' or 'OTS (One Time Service)'
child.against_doctype = self.doc.doctype
child.against_docname = self.doc.name
child.customer = self.doc.customer
child.territory = self.doc.territory
child.save()
sr.warranty_amc_status = (self.doc.order_type == 'AMC') and 'Under AMC' or 'OTS (One Time Service)'
sr.amc_expiry_date = d.end_date
sr.save()
sr_list.append(d.serial_no)
else:
sql("delete from `tabWarranty AMC History` where against_doctype = %s and against_docname = %s", (self.doc.doctype, self.doc.name))
for d in getlist(self.doclist, 'service_order_details'):
sql("update `tabSerial No` set amc_expiry_date = '' where name = '%s'" % (d.serial_no))
sr_list.append(d.serial_no)
self.update_serial_no_warranty_amc_status(serial_no_list = sr_list)
示例12: 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)
set(self.doc, 'status', 'Submitted')
示例13: 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
示例14: validate_reference_value
def validate_reference_value(self, obj, to_docname):
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()
示例15: 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