本文整理汇总了Python中webnotes.model.doc.addchild函数的典型用法代码示例。如果您正苦于以下问题:Python addchild函数的具体用法?Python addchild怎么用?Python addchild使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了addchild函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_item_details
def get_item_details(self):
items=webnotes.conn.sql(""" select item,quantity,description,warehouse from `tabItem Detail`
where parent=%s""",(self.doc.special_type_project),as_dict=1)
employee=webnotes.conn.sql(""" select employee,employee_name,employee_contact_no from `tabEmployee Detail`
where parent=%s""",(self.doc.special_type_project),as_dict=1)
#webnotes.errprint(milestone)
for d in items:
#self.doclist=self.doc.clear_table(self.doclist,'')
ch = addchild(self.doc, 'item_details_table',
'Item Detail', self.doclist)
#webnotes.errprint(t[0])
ch.item = d.get('item')
ch.quantity= d.get('quantity')
ch.description=d.get('description')
ch.warehouse=d.get('warehouse')
#webnotes.errprint(ch)
for t in employee:
ch = addchild(self.doc, 'employee_details_table',
'Employee Detail', self.doclist)
#webnotes.errprint(t[0])
ch.employee=t.get('employee')
ch.employee_name= t.get('employee_name')
ch.employee_contact_no=t.get('employee_contact_no')
示例2: upload_accounts_transactions
def upload_accounts_transactions(self):
import csv
data = csv.reader(self.get_csv_data().splitlines())
abbr = sql("select concat(' - ',abbr) as abbr from tabCompany where name=%s", self.doc.company)
updated = 0
jv_name = ""
# jv = Document('Journal Voucher')
global line, jv, name, jv_go
for line in data:
if len(line) >= 7: # Minimum no of fields
if line[3] != jv_name: # Create JV
if jv_name != "":
jv_go = get_obj("Journal Voucher", name, with_children=1)
jv_go.validate()
jv_go.on_submit()
jv_name = line[3]
jv = Document("Journal Voucher")
jv.voucher_type = line[0]
jv.naming_series = line[1]
jv.voucher_date = formatdate(line[2])
jv.posting_date = formatdate(line[2])
# jv.name = line[3]
jv.fiscal_year = self.doc.fiscal_year
jv.company = self.doc.company
jv.remark = len(line) == 8 and line[3] + " " + line[7] or line[3] + " Uploaded Record"
jv.docstatus = 1
jv.save(1)
name = jv.name
jc = addchild(jv, "entries", "Journal Voucher Detail", 0)
jc.account = line[4] + abbr[0][0]
jc.cost_center = len(line) == 9 and line[8] or self.doc.default_cost_center
if line[5] != "":
jc.debit = line[5]
else:
jc.credit = line[6]
jc.save()
else: # Create JV Child
jc = addchild(jv, "entries", "Journal Voucher Detail", 0)
jc.account = line[4] + abbr[0][0]
jc.cost_center = len(line) == 9 and line[8] or self.doc.default_cost_center
if line[5] != "":
jc.debit = line[5]
else:
jc.credit = line[6]
jc.save()
else:
msgprint("[Ignored] Incorrect format: %s" % str(line))
if jv_name != "":
jv_go = get_obj("Journal Voucher", name, with_children=1)
jv_go.validate()
jv_go.on_submit()
msgprint("<b>%s</b> items updated" % updated)
示例3: execute
def execute():
import webnotes
from webnotes.model import delete_doc
from webnotes.model.code import get_obj
from webnotes.model.doc import addchild
# delete doctypes and tables
for dt in [
"TDS Payment",
"TDS Return Acknowledgement",
"Form 16A",
"TDS Rate Chart",
"TDS Category",
"TDS Control",
"TDS Detail",
"TDS Payment Detail",
"TDS Rate Detail",
"TDS Category Account",
"Form 16A Ack Detail",
"Form 16A Tax Detail",
]:
delete_doc("DocType", dt)
webnotes.conn.commit()
webnotes.conn.sql("drop table if exists `tab%s`" % dt)
webnotes.conn.begin()
delete_doc("Search Criteria", "tds_return")
# Add tds entry in tax table for purchase invoice
pi_list = webnotes.conn.sql(
"""select name from `tabPurchase Invoice`
where ifnull(tax_code, '')!='' and ifnull(ded_amount, 0)!=0"""
)
for pi in pi_list:
piobj = get_obj("Purchase Invoice", pi[0], with_children=1)
ch = addchild(piobj.doc, "taxes_and_charges", "Purchase Taxes and Charges")
ch.charge_type = "Actual"
ch.account_head = piobj.doc.tax_code
ch.description = piobj.doc.tax_code
ch.rate = -1 * piobj.doc.ded_amount
ch.tax_amount = -1 * piobj.doc.ded_amount
ch.category = "Total"
ch.save(1)
# Add tds entry in entries table for journal voucher
jv_list = webnotes.conn.sql(
"""select name from `tabJournal Voucher`
where ifnull(tax_code, '')!='' and ifnull(ded_amount, 0)!=0"""
)
for jv in jv_list:
jvobj = get_obj("Journal Voucher", jv[0], with_children=1)
ch = addchild(jvobj.doc, "entries", "Journal Voucher Detail")
ch.account = jvobj.doc.tax_code
ch.credit = jvobj.doc.ded_amount
ch.save(1)
示例4: fetch_gases
def fetch_gases(self):
gases = webnotes.conn.sql("select name from tabGas where name!='TGC'")
self.doclist=self.doc.clear_table(self.doclist,'dissolved_gas_detail')
if gases:
nl = addchild(self.doc, 'dissolved_gas_detail', 'Dissolved Gas Analysis Detail', self.doclist)
nl.gas='TGC'
for gas in gases:
nl = addchild(self.doc, 'dissolved_gas_detail', 'Dissolved Gas Analysis Detail', self.doclist)
nl.gas = gas
else:
webnotes.msgprint("There is no any Gas Recorded In Gas Table")
示例5: add_roles
def add_roles(self, pr):
roles_list = ['Accounts Manager', 'Accounts User', 'Blogger', 'HR Manager', 'HR User', 'Maintenance User', 'Maintenance Manager', 'Material Manager', 'Material User', 'Material Master Manager', 'Production Manager', 'Production User', 'Projects User', 'Purchase Manager', 'Purchase User', 'Purchase Master Manager', 'Quality Manager', 'Sales Manager', 'Sales User', 'Sales Master Manager', 'Support Manager', 'Support Team', 'System Manager', 'Website Manager']
for r in roles_list:
d = addchild(pr, 'userroles', 'UserRole', 1)
d.role = r
d.save(1)
# Add roles to Administrator profile
pr = Document('Profile','Administrator')
for r in roles_list:
d = addchild(pr,'userroles', 'UserRole', 1)
d.role = r
d.save(1)
示例6: get_open_sales_order
def get_open_sales_order(self):
if not (self.doc.from_date and self.doc.to_date):
msgprint("From Date and To Date are Mandatory")
return
cond = ''
if self.doc.customer:
cond += " AND t1.customer = '%s' " % self.doc.customer
if self.doc.sales_order:
cond += " AND t1.name = '%s' " % self.doc.sales_order
if self.doc.territory:
cond += " AND t1.territory = '%s' " %self.doc.territory
dl = sql("select distinct t1.name, t1.customer, t1.delivery_date, t1.territory, t1.rounded_total from `tabSales Order` t1, `tabSales Order Detail` t2 where t1.transaction_date >= '%s' and t1.transaction_date <= '%s' and t1.docstatus=1 and t1.status != 'Completed' and t1.name = t2.parent and t2.docstatus =1 and t2.qty > t2.delivered_qty and (t2.confirmation_date is null or t2.confirmation_date= '' or t2.confirmation_date='0000-00-00') %s"% (self.doc.from_date, self.doc.to_date, cond))
self.doc.clear_table(self.doclist, 'entries')
count = 0
for d in dl:
nl = addchild(self.doc, 'entries', 'Update Delivery Date Detail', 1, self.doclist)
nl.sales_order_no = str(d[0])
nl.customer = str(d[1])
nl.territory = str(d[3])
nl.rounded_total = str(d[4])
nl.delivery_date = str(d[2])
count = count +1
if not count:
msgprint("No Sales Order found as per filters set.")
示例7: update_against_doc
def update_against_doc(d, jv_obj):
"""
Updates against document, if partial amount splits into rows
"""
webnotes.conn.sql("""
update `tabJournal Voucher Detail` t1, `tabJournal Voucher` t2
set t1.%(dr_or_cr)s = '%(allocated_amt)s',
t1.%(against_fld)s = '%(against_voucher)s', t2.modified = now()
where t1.name = '%(voucher_detail_no)s' and t1.parent = t2.name""" % d)
if d['allocated_amt'] < d['unadjusted_amt']:
jvd = webnotes.conn.sql("""select cost_center, balance, against_account, is_advance
from `tabJournal Voucher Detail` where name = %s""", d['voucher_detail_no'])
# new entry with balance amount
ch = addchild(jv_obj.doc, 'entries', 'Journal Voucher Detail')
ch.account = d['account']
ch.cost_center = cstr(jvd[0][0])
ch.balance = cstr(jvd[0][1])
ch.fields[d['dr_or_cr']] = flt(d['unadjusted_amt']) - flt(d['allocated_amt'])
ch.fields[d['dr_or_cr']== 'debit' and 'credit' or 'debit'] = 0
ch.against_account = cstr(jvd[0][2])
ch.is_advance = cstr(jvd[0][3])
ch.docstatus = 1
ch.save(1)
示例8: reorder_indent
def reorder_indent(self,i,item_reorder_level,doc_type,doc_name,email_notify=1):
indent = Document('Indent')
indent.transaction_date = nowdate()
indent.naming_series = 'IDT'
indent.company = get_defaults()['company']
indent.fiscal_year = get_defaults()['fiscal_year']
indent.remark = "This is an auto generated Indent. It was raised because the projected quantity has fallen below the minimum re-order level when %s %s was created"%(doc_type,doc_name)
indent.save(1)
indent_obj = get_obj('Indent',indent.name,with_children=1)
indent_details_child = addchild(indent_obj.doc,'indent_details','Indent Detail',0)
indent_details_child.item_code = self.doc.item_code
indent_details_child.uom = self.doc.stock_uom
indent_details_child.warehouse = self.doc.warehouse
indent_details_child.schedule_date= add_days(nowdate(),cint(i['lead_time_days']))
indent_details_child.item_name = i['item_name']
indent_details_child.description = i['description']
indent_details_child.item_group = i['item_group']
if (i['min_order_qty'] < ( flt(item_reorder_level)-flt(self.doc.projected_qty) )):
indent_details_child.qty =flt(flt(item_reorder_level)-flt(self.doc.projected_qty))
else:
indent_details_child.qty = i['min_order_qty']
indent_details_child.brand = i['brand']
indent_details_child.save()
indent_obj = get_obj('Indent',indent.name,with_children=1)
indent_obj.validate()
set(indent_obj.doc,'docstatus',1)
indent_obj.on_submit()
msgprint("Item: " + self.doc.item_code + " is to be re-ordered. Indent %s raised.Was generated from %s %s"%(indent.name,doc_type, doc_name ))
if(email_notify):
send_email_notification(doc_type,doc_name)
示例9: add_charges_in_pr
def add_charges_in_pr(self):
""" Add additional charges in selected pr proportionately"""
total_amt = self.get_total_amt()
for pr in self.selected_pr:
pr_obj = get_obj('Purchase Receipt', pr, with_children = 1)
cumulative_grand_total = flt(pr_obj.doc.grand_total)
for lc in getlist(self.doclist, 'landed_cost_details'):
amt = flt(lc.amount) * flt(pr_obj.doc.net_total)/ flt(total_amt)
self.prwise_cost[pr] = self.prwise_cost.get(pr, 0) + amt
cumulative_grand_total += amt
pr_oc_row = sql("select name from `tabPurchase Taxes and Charges` where parent = %s and category = 'Valuation' and add_deduct_tax = 'Add' and charge_type = 'Actual' and account_head = %s",(pr, lc.account_head))
if not pr_oc_row: # add if not exists
ch = addchild(pr_obj.doc, 'purchase_tax_details', 'Purchase Taxes and Charges', 1)
ch.category = 'Valuation'
ch.add_deduct_tax = 'Add'
ch.charge_type = 'Actual'
ch.description = lc.description
ch.account_head = lc.account_head
ch.rate = amt
ch.tax_amount = amt
ch.total = cumulative_grand_total
ch.docstatus = 1
ch.idx = 500 # add at the end
ch.save(1)
else: # overwrite if exists
sql("update `tabPurchase Taxes and Charges` set rate = %s, tax_amount = %s where name = %s and parent = %s ", (amt, amt, pr_oc_row[0][0], pr))
示例10: create_auto_indent
def create_auto_indent(self, i , doc_type, doc_name, cur_qty):
""" Create indent on reaching reorder level """
indent = Document('Purchase Request')
indent.transaction_date = nowdate()
indent.naming_series = 'IDT'
indent.company = get_defaults()['company']
indent.fiscal_year = get_defaults()['fiscal_year']
indent.remark = "This is an auto generated Purchase Request. It was raised because the (actual + ordered + indented - reserved) quantity reaches re-order level when %s %s was created"%(doc_type,doc_name)
indent.save(1)
indent_obj = get_obj('Purchase Request',indent.name,with_children=1)
indent_details_child = addchild(indent_obj.doc,'indent_details','Purchase Request Item',0)
indent_details_child.item_code = self.doc.item_code
indent_details_child.uom = self.doc.stock_uom
indent_details_child.warehouse = self.doc.warehouse
indent_details_child.schedule_date= add_days(nowdate(),cint(i['lead_time_days']))
indent_details_child.item_name = i['item_name']
indent_details_child.description = i['description']
indent_details_child.item_group = i['item_group']
indent_details_child.qty = i['re_order_qty'] or (flt(i['re_order_level']) - flt(cur_qty))
indent_details_child.brand = i['brand']
indent_details_child.save()
indent_obj = get_obj('Purchase Request',indent.name,with_children=1)
indent_obj.validate()
set(indent_obj.doc,'docstatus',1)
indent_obj.on_submit()
msgprint("Item: " + self.doc.item_code + " is to be re-ordered. Purchase Request %s raised. It was generated from %s %s"%(indent.name,doc_type, doc_name ))
if(i['email_notify']):
send_email_notification(doc_type,doc_name)
示例11: 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)
示例12: on_update
def on_update(self):
bin = sql("select stock_uom from `tabBin` where item_code = '%s' " % self.doc.item_code)
if bin and cstr(bin[0][0]) != cstr(self.doc.stock_uom):
msgprint("Please Update Stock UOM with the help of Stock UOM Replace Utility.")
raise Exception
check_list = []
for d in getlist(self.doclist,'uom_conversion_details'):
if not self.doc.stock_uom:
msgprint("Please enter Stock UOM first.")
raise Exception
if cstr(d.uom) in check_list:
msgprint("UOM %s has been entered more than once in Conversion Factor Details." % cstr(d.uom))
raise Exception
if not cstr(d.uom) in check_list:
check_list.append(cstr(d.uom))
if cstr(d.uom) == cstr(self.doc.stock_uom):
if flt(d.conversion_factor) != 1:
msgprint("Conversion Fator of UOM : %s should be equal to 1. As UOM : %s is Stock UOM of Item: %s." % ( cstr(d.uom), cstr(d.uom), cstr(self.doc.name)))
raise Exception
# else set uom_exist as true
uom_exist='true'
elif cstr(d.uom) != cstr(self.doc.stock_uom) and flt(d.conversion_factor) == 1:
msgprint("Conversion Factor of UOM : %s should not be equal to 1. As UOM : %s is not Stock UOM of Item: %s." % ( cstr(d.uom), cstr(d.uom), cstr(self.doc.name)))
raise Exception
if not cstr(self.doc.stock_uom) in check_list :
child = addchild( self.doc, 'uom_conversion_details', 'UOM Conversion Detail', 1, self.doclist)
child.uom = self.doc.stock_uom
child.conversion_factor = 1
child.save()
示例13: get_weekly_off_date_list
def get_weekly_off_date_list(self, year_start_date, year_end_date):
from webnotes.utils import getdate
year_start_date, year_end_date = getdate(year_start_date), getdate(year_end_date)
from dateutil import relativedelta
from datetime import timedelta
import calendar
date_list = []
date_list1 = []
if self.doc.weekly_off=='3rd Saturday':
webnotes.errprint(self.doc.weekly_off)
weekday = getattr(calendar, ('Saturday').upper())
reference_date = year_start_date + relativedelta.relativedelta(weekday=weekday)
while reference_date <= year_end_date:
date_list1.append(reference_date)
reference_date += timedelta(days=7)
for dt in date_list1:
if dt.day>14 :
if dt.day <22:
#webnotes.errprint(dt)
ch = addchild(self.doc, 'holiday_list_details', 'Holiday', self.doclist)
ch.description = self.doc.weekly_off
ch.holiday_date = dt
return date_list
else:
weekday = getattr(calendar, (self.doc.weekly_off).upper())
reference_date = year_start_date + relativedelta.relativedelta(weekday=weekday)
while reference_date <= year_end_date:
date_list.append(reference_date)
reference_date += timedelta(days=7)
return date_list
示例14: update_ref_rate
def update_ref_rate(self, i):
ref_rate, count, p, currency = 0, 0, self.doc.price_list, self.doc.currency
if not cstr(self.doc.price_list):
msgprint("Please enter Price List.")
raise Exception
if not cstr(self.doc.currency):
msgprint("Please enter Currency.")
raise Exception
for d in getlist(self.doclist, "sales_bom_items"):
item_rate = sql(
"select ref_rate,ref_currency from `tabRef Rate Detail` where price_list_name=%s and parent=%s",
(p, d.item_code),
)
if not item_rate:
msgprint(
"Item %s does not have a rate for Price List %s. Did not update rates for this Price List"
% (d.item_code, p)
)
raise Exception
# if count == 0 : currency = cstr(item_rate[0][1])
if not cstr(currency) == cstr(item_rate[0][1]):
msgprint(
"Item %s currency %s does not match with other items currency i.e. %s "
% (d.item_code, item_rate[0][1], currency)
)
raise Exception
count += 1
ref_rate += flt(d.qty) * flt(item_rate[0][0])
pld = addchild(i, "ref_rate_details", "Ref Rate Detail")
pld.price_list_name = p
pld.ref_rate = flt(ref_rate)
pld.ref_currency = currency
pld.save()
示例15: get_tds
def get_tds(self):
self.doc.clear_table(self.doclist, "form_16A_tax_details")
import datetime
if self.doc.from_date and self.doc.to_date and self.doc.tds_category:
tot = 0.0
party_tds_list = sql(
"select t2.amount_paid,t2.date_of_payment,t2.tds_amount,t2.cess_on_tds, t2.total_tax_amount, t1.cheque_no, t1.bsr_code, t1.date_of_receipt, t1.challan_no from `tabTDS Payment` t1, `tabTDS Payment Detail` t2 where t1.tds_category='%s' and t2.party_name='%s' and t1.from_date >= '%s' and t1.to_date <= '%s' and t2.total_tax_amount>0 and t2.parent=t1.name and t1.docstatus=1"
% (self.doc.tds_category, self.doc.party_name, self.doc.from_date, self.doc.to_date)
)
for s in party_tds_list:
child = addchild(self.doc, "form_16A_tax_details", "Form 16A Tax Detail", 1, self.doclist)
child.amount_paid = s and flt(s[0]) or ""
child.date_of_payment = s and s[1].strftime("%Y-%m-%d") or ""
child.tds_main = s and flt(s[2]) or ""
child.surcharge = 0
child.cess_on_tds = s and flt(s[3]) or ""
child.total_tax_deposited = s and flt(s[4]) or ""
child.cheque_no = s and s[5] or ""
child.bsr_code = s and s[6] or ""
child.tax_deposited_date = s and s[7].strftime("%Y-%m-%d") or ""
child.challan_no = s and s[8] or ""
tot = flt(tot) + flt(s[4])
self.doc.total_amount = flt(tot)
else:
msgprint("Plaese enter from date, to date and TDS category")