addchild will never save added doc
This commit is contained in:
parent
acc36be87f
commit
f5d90abe92
@ -42,7 +42,7 @@ class DocType:
|
||||
self.doc.total_amount = 0.0
|
||||
|
||||
for d in dl:
|
||||
nl = addchild(self.doc, 'entries', 'Bank Reconciliation Detail', 1, self.doclist)
|
||||
nl = addchild(self.doc, 'entries', 'Bank Reconciliation Detail', self.doclist)
|
||||
nl.posting_date = cstr(d[5])
|
||||
nl.voucher_id = cstr(d[0])
|
||||
nl.cheque_number = cstr(d[1])
|
||||
|
@ -31,7 +31,8 @@ class DocType:
|
||||
'October','November','December']
|
||||
idx =1
|
||||
for m in month_list:
|
||||
mnth = addchild(self.doc,'budget_distribution_details','Budget Distribution Detail',1,self.doclist)
|
||||
mnth = addchild(self.doc, 'budget_distribution_details',
|
||||
'Budget Distribution Detail', self.doclist)
|
||||
mnth.month = m or ''
|
||||
mnth.idx = idx
|
||||
idx += 1
|
||||
|
@ -223,7 +223,7 @@ class DocType:
|
||||
obj.doclist = obj.doc.clear_table(obj.doclist,table_field_name)
|
||||
# Create advance table
|
||||
for d in jv_detail:
|
||||
add = addchild(obj.doc, table_field_name, table_name, 1, obj.doclist)
|
||||
add = addchild(obj.doc, table_field_name, table_name, obj.doclist)
|
||||
add.journal_voucher = d[0]
|
||||
add.jv_detail_no = d[3]
|
||||
add.remarks = d[1]
|
||||
@ -286,7 +286,7 @@ class DocType:
|
||||
webnotes.conn.sql("update `tabJournal Voucher Detail` set %s = '%s', %s = '%s' where name = '%s'" % (dr_or_cr, flt(allocate), doctype == "Purchase Invoice" and 'against_voucher' or 'against_invoice',cstr(against_document_no), jv_detail_no))
|
||||
|
||||
# new entry with balance amount
|
||||
add = addchild(jv_obj.doc, 'entries', 'Journal Voucher Detail', 1, jv_obj.doclist)
|
||||
add = addchild(jv_obj.doc, 'entries', 'Journal Voucher Detail', jv_obj.doclist)
|
||||
add.account = account_head
|
||||
add.cost_center = cstr(jvd[0][1])
|
||||
add.balance = cstr(jvd[0][2])
|
||||
@ -353,7 +353,7 @@ class DocType:
|
||||
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', 1)
|
||||
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])
|
||||
|
@ -174,7 +174,7 @@ class DocType:
|
||||
|
||||
# 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)
|
||||
jd = addchild(self.doc, 'entries', 'Journal Voucher Detail', self.doclist)
|
||||
if diff>0:
|
||||
jd.credit = flt(diff)
|
||||
elif diff<0:
|
||||
@ -256,7 +256,7 @@ class DocType:
|
||||
total = 0
|
||||
for d in self.get_values():
|
||||
total += flt(d[2])
|
||||
jd = addchild(self.doc, 'entries', 'Journal Voucher Detail', 1, self.doclist)
|
||||
jd = addchild(self.doc, 'entries', 'Journal Voucher Detail', self.doclist)
|
||||
jd.account = cstr(d[1])
|
||||
if self.doc.write_off_based_on == 'Accounts Receivable':
|
||||
jd.credit = flt(d[2])
|
||||
@ -265,7 +265,7 @@ class DocType:
|
||||
jd.debit = flt(d[2])
|
||||
jd.against_voucher = cstr(d[0])
|
||||
jd.save(1)
|
||||
jd = addchild(self.doc, 'entries', 'Journal Voucher Detail', 1, self.doclist)
|
||||
jd = addchild(self.doc, 'entries', 'Journal Voucher Detail', self.doclist)
|
||||
if self.doc.write_off_based_on == 'Accounts Receivable':
|
||||
jd.debit = total
|
||||
elif self.doc.write_off_based_on == 'Accounts Payable':
|
||||
|
@ -100,7 +100,7 @@ class DocType:
|
||||
#--------------------------------------------------
|
||||
def create_payment_table(self, gle):
|
||||
for d in gle:
|
||||
ch = addchild(self.doc, 'ir_payment_details', 'Payment to Invoice Matching Tool Detail', 1, self.doclist)
|
||||
ch = addchild(self.doc, 'ir_payment_details', 'Payment to Invoice Matching Tool Detail', self.doclist)
|
||||
ch.voucher_no = d.get('voucher_no')
|
||||
ch.posting_date = d.get('posting_date')
|
||||
ch.amt_due = self.acc_type == 'debit' and flt(d.get('amt_due')) or -1*flt(d.get('amt_due'))
|
||||
|
@ -612,7 +612,8 @@ class DocType(TransactionBase):
|
||||
|
||||
idx = 0
|
||||
for other in other_charge:
|
||||
d = addchild(obj.doc, 'purchase_tax_details', 'Purchase Taxes and Charges', 1, obj.doclist)
|
||||
d = addchild(obj.doc, 'purchase_tax_details', 'Purchase Taxes and Charges',
|
||||
obj.doclist)
|
||||
d.category = other['category']
|
||||
d.add_deduct_tax = other['add_deduct_tax']
|
||||
d.charge_type = other['charge_type']
|
||||
|
@ -314,7 +314,7 @@ class DocType(TransactionBase):
|
||||
for i in bom_det:
|
||||
if i and not sql("select name from `tabPurchase Order Item Supplied` where reference_name = '%s' and bom_detail_no = '%s' and parent = '%s' " %(d.name, i[6], self.doc.name)):
|
||||
|
||||
rm_child = addchild(self.doc, 'po_raw_material_details', 'Purchase Order Item Supplied', 1, self.doclist)
|
||||
rm_child = addchild(self.doc, 'po_raw_material_details', 'Purchase Order Item Supplied', self.doclist)
|
||||
|
||||
rm_child.reference_name = d.name
|
||||
rm_child.bom_detail_no = i and i[6] or ''
|
||||
|
@ -41,7 +41,7 @@ class DocType:
|
||||
specification = sql("select specification, value from `tabItem Quality Inspection Parameter` \
|
||||
where parent = '%s' order by idx" % (self.doc.item_code))
|
||||
for d in specification:
|
||||
child = addchild(self.doc, 'qa_specification_details', 'Quality Inspection Reading', 1, self.doclist)
|
||||
child = addchild(self.doc, 'qa_specification_details', 'Quality Inspection Reading', self.doclist)
|
||||
child.specification = d[0]
|
||||
child.value = d[1]
|
||||
child.status = 'Accepted'
|
||||
|
@ -19,7 +19,7 @@ import webnotes
|
||||
import webnotes.model
|
||||
from webnotes import _, msgprint
|
||||
from webnotes.utils import cint, flt
|
||||
from webnotes.model.utils import round_doc
|
||||
from webnotes.model.utils import round_floats_in_doc
|
||||
import json
|
||||
|
||||
from controllers.transaction_controller import TransactionController
|
||||
@ -83,7 +83,7 @@ class TaxController(TransactionController):
|
||||
self.precision.item[base_field])
|
||||
|
||||
for item in self.item_doclist:
|
||||
round_doc(item, self.precision.item)
|
||||
round_floats_in_doc(item, self.precision.item)
|
||||
|
||||
if item.fields.get(self.fmap.discount) == 100:
|
||||
if not item.fields.get(self.fmap.print_ref_rate):
|
||||
@ -126,7 +126,7 @@ class TaxController(TransactionController):
|
||||
self.validate_included_tax(tax)
|
||||
|
||||
# round relevant values
|
||||
round_doc(tax, self.precision.tax)
|
||||
round_floats_in_doc(tax, self.precision.tax)
|
||||
|
||||
def calculate_net_total(self):
|
||||
self.doc.net_total = 0
|
||||
|
@ -99,7 +99,7 @@ class DocType:
|
||||
yr_start_date, yr_end_date = self.get_fy_start_end_dates()
|
||||
date_list = self.get_weekly_off_date_list(yr_start_date, yr_end_date)
|
||||
for d in date_list:
|
||||
ch = addchild(self.doc, 'holiday_list_details', 'Holiday', 1, self.doclist)
|
||||
ch = addchild(self.doc, 'holiday_list_details', 'Holiday', self.doclist)
|
||||
ch.description = self.doc.weekly_off
|
||||
ch.holiday_date = d
|
||||
|
||||
|
@ -70,7 +70,7 @@ class DocType:
|
||||
def make_table(self, doct_name, tab_fname, tab_name):
|
||||
list1 = sql("select name from `tab%s` where docstatus != 2" % doct_name)
|
||||
for li in list1:
|
||||
child = addchild(self.doc, tab_fname, tab_name, 1, self.doclist)
|
||||
child = addchild(self.doc, tab_fname, tab_name, self.doclist)
|
||||
if(tab_fname == 'earning_details'):
|
||||
child.e_type = cstr(li[0])
|
||||
child.modified_value = 0
|
||||
|
@ -357,7 +357,8 @@ class DocType:
|
||||
"Add items to Flat BOM table"
|
||||
self.doclist = self.doc.clear_table(self.doclist, 'flat_bom_details', 1)
|
||||
for d in self.cur_exploded_items:
|
||||
ch = addchild(self.doc, 'flat_bom_details', 'BOM Explosion Item', 1, self.doclist)
|
||||
ch = addchild(self.doc, 'flat_bom_details', 'BOM Explosion Item',
|
||||
self.doclist)
|
||||
for i in d.keys():
|
||||
ch.fields[i] = d[i]
|
||||
ch.docstatus = self.doc.docstatus
|
||||
|
@ -101,7 +101,7 @@ class DocType:
|
||||
for r in open_so:
|
||||
if cstr(r['name']) not in so_list:
|
||||
pp_so = addchild(self.doc, 'pp_so_details',
|
||||
'Production Plan Sales Order', 1, self.doclist)
|
||||
'Production Plan Sales Order', self.doclist)
|
||||
pp_so.sales_order = r['name']
|
||||
pp_so.sales_order_date = cstr(r['transaction_date'])
|
||||
pp_so.customer = cstr(r['customer'])
|
||||
@ -150,7 +150,7 @@ class DocType:
|
||||
for p in items:
|
||||
item_details = sql("""select description, stock_uom, default_bom
|
||||
from tabItem where name=%s""", p['item_code'])
|
||||
pi = addchild(self.doc, 'pp_details', 'Production Plan Item', 1, self.doclist)
|
||||
pi = addchild(self.doc, 'pp_details', 'Production Plan Item', self.doclist)
|
||||
pi.sales_order = p['parent']
|
||||
pi.item_code = p['item_code']
|
||||
pi.description = item_details and item_details[0][0] or ''
|
||||
|
@ -7,7 +7,7 @@ def execute():
|
||||
webnotes.conn.sql("delete from `tabDocPerm` where role = 'All' and permlevel = 0 and parent in ('Appraisal', 'Ticket', 'Project')")
|
||||
|
||||
appr = get_obj('DocType', 'Appraisal', with_children=1)
|
||||
ch = addchild(appr.doc, 'permissions', 'DocPerm', 0)
|
||||
ch = addchild(appr.doc, 'permissions', 'DocPerm')
|
||||
ch.permlevel = 0
|
||||
ch.role = 'Employee'
|
||||
ch.read = 1
|
||||
|
@ -11,7 +11,7 @@ def execute():
|
||||
|
||||
addr = get_obj('DocType', 'Address', with_children=1)
|
||||
for d in role1+role2:
|
||||
ch = addchild(addr.doc, 'permissions', 'DocPerm', 0)
|
||||
ch = addchild(addr.doc, 'permissions', 'DocPerm')
|
||||
ch.role = d
|
||||
ch.read = 1
|
||||
ch.write = 1
|
||||
|
@ -123,7 +123,7 @@ class DocType(TransactionBase):
|
||||
user_lst.append(chk[0][0])
|
||||
|
||||
for d in user_lst:
|
||||
ch = addchild(ev, 'event_individuals', 'Event User', 0)
|
||||
ch = addchild(ev, 'event_individuals', 'Event User')
|
||||
ch.person = d
|
||||
ch.save(1)
|
||||
|
||||
|
@ -19,7 +19,7 @@ import webnotes
|
||||
|
||||
from webnotes.utils import cstr, load_json
|
||||
from webnotes.model import db_exists
|
||||
from webnotes.model.doc import Document, addchild
|
||||
from webnotes.model.doc import Document
|
||||
from webnotes.model.wrapper import getlist, copy_doclist
|
||||
from webnotes.model.code import get_obj
|
||||
from webnotes import msgprint
|
||||
|
@ -75,7 +75,7 @@ class DocType(TransactionBase):
|
||||
obj.doclist = obj.doc.clear_table(obj.doclist,'sales_team')
|
||||
idx = 0
|
||||
for d in webnotes.conn.sql("select sales_person, allocated_percentage, allocated_amount, incentives from `tabSales Team` where parent = '%s'" % obj.doc.customer):
|
||||
ch = addchild(obj.doc, 'sales_team', 'Sales Team', 1, obj.doclist)
|
||||
ch = addchild(obj.doc, 'sales_team', 'Sales Team', obj.doclist)
|
||||
ch.sales_person = d and cstr(d[0]) or ''
|
||||
ch.allocated_percentage = d and flt(d[1]) or 0
|
||||
ch.allocated_amount = d and flt(d[2]) or 0
|
||||
@ -265,7 +265,7 @@ class DocType(TransactionBase):
|
||||
for field in default_fields:
|
||||
if field in other: del other[field]
|
||||
|
||||
d = addchild(obj.doc, 'other_charges', 'Sales Taxes and Charges', 1,
|
||||
d = addchild(obj.doc, 'other_charges', 'Sales Taxes and Charges',
|
||||
obj.doclist)
|
||||
d.fields.update(other)
|
||||
d.rate = flt(d.rate)
|
||||
@ -481,7 +481,8 @@ class DocType(TransactionBase):
|
||||
break
|
||||
|
||||
if not exists:
|
||||
pi = addchild(obj.doc, 'packing_details', 'Delivery Note Packing Item', 1, obj.doclist)
|
||||
pi = addchild(obj.doc, 'packing_details', 'Delivery Note Packing Item',
|
||||
obj.doclist)
|
||||
|
||||
pi.parent_item = line.item_code
|
||||
pi.item_code = packing_item_code
|
||||
|
@ -239,13 +239,13 @@ class DocType:
|
||||
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', 'Manufacturing Manager', 'Manufacturing 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 = addchild(pr, 'userroles', 'UserRole')
|
||||
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 = addchild(pr,'userroles', 'UserRole')
|
||||
d.role = r
|
||||
d.save(1)
|
@ -350,7 +350,7 @@ class DocType:
|
||||
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 = addchild(indent_obj.doc,'indent_details','Purchase Request Item')
|
||||
indent_details_child.item_code = self.doc.item_code
|
||||
indent_details_child.uom = self.doc.stock_uom
|
||||
indent_details_child.warehouse = self.doc.warehouse
|
||||
|
@ -70,7 +70,8 @@ class DocType:
|
||||
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 = addchild( self.doc, 'uom_conversion_details',
|
||||
'UOM Conversion Detail', self.doclist)
|
||||
child.uom = self.doc.stock_uom
|
||||
child.conversion_factor = 1
|
||||
child.save()
|
||||
|
@ -51,7 +51,8 @@ class DocType:
|
||||
msgprint("Please enter date of shorter duration as there are too many purchase receipt, hence it cannot be loaded.", raise_exception=1)
|
||||
|
||||
for i in pr:
|
||||
ch = addchild(self.doc, 'lc_pr_details', 'Landed Cost Purchase Receipt', 1, self.doclist)
|
||||
ch = addchild(self.doc, 'lc_pr_details', 'Landed Cost Purchase Receipt',
|
||||
self.doclist)
|
||||
ch.purchase_receipt = i and i['name'] or ''
|
||||
ch.save()
|
||||
|
||||
@ -62,7 +63,8 @@ class DocType:
|
||||
idx = 0
|
||||
landed_cost = sql("select account_head, description from `tabLanded Cost Master Detail` where parent=%s", (self.doc.landed_cost), as_dict = 1)
|
||||
for cost in landed_cost:
|
||||
lct = addchild(self.doc, 'landed_cost_details', 'Landed Cost Item', 1, self.doclist)
|
||||
lct = addchild(self.doc, 'landed_cost_details', 'Landed Cost Item',
|
||||
self.doclist)
|
||||
lct.account_head = cost['account_head']
|
||||
lct.description = cost['description']
|
||||
|
||||
@ -100,7 +102,7 @@ class DocType:
|
||||
|
||||
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 = addchild(pr_obj.doc, 'purchase_tax_details', 'Purchase Taxes and Charges')
|
||||
ch.category = 'Valuation'
|
||||
ch.add_deduct_tax = 'Add'
|
||||
ch.charge_type = 'Actual'
|
||||
|
@ -390,7 +390,7 @@ class DocType(TransactionBase):
|
||||
|
||||
if i and not sql("select name from `tabPurchase Receipt Item Supplied` where reference_name = '%s' and bom_detail_no = '%s' and parent = '%s' " %(d.name, i[6], self.doc.name)):
|
||||
|
||||
rm_child = addchild(self.doc, 'pr_raw_material_details', 'Purchase Receipt Item Supplied', 1, self.doclist)
|
||||
rm_child = addchild(self.doc, 'pr_raw_material_details', 'Purchase Receipt Item Supplied', self.doclist)
|
||||
|
||||
rm_child.reference_name = d.name
|
||||
rm_child.bom_detail_no = i and i[6] or ''
|
||||
|
@ -52,7 +52,8 @@ class DocType :
|
||||
def create_item_table(self, det):
|
||||
self.doclist = self.doc.clear_table(self.doclist, 'return_details', 1)
|
||||
for i in det:
|
||||
ch = addchild(self.doc, 'return_details', 'Sales and Purchase Return Item', 1, self.doclist)
|
||||
ch = addchild(self.doc, 'return_details', 'Sales and Purchase Return Item',
|
||||
self.doclist)
|
||||
ch.detail_name = i and i[0] or ''
|
||||
ch.item_code = i and i[1] or ''
|
||||
ch.description = i and i[2] or ''
|
||||
|
@ -467,7 +467,8 @@ class DocType(TransactionBase):
|
||||
|
||||
def add_to_stock_entry_detail(self, source_wh, target_wh, item_dict, bom_no=None):
|
||||
for d in item_dict:
|
||||
se_child = addchild(self.doc, 'mtn_details', 'Stock Entry Detail', 0, self.doclist)
|
||||
se_child = addchild(self.doc, 'mtn_details', 'Stock Entry Detail',
|
||||
self.doclist)
|
||||
se_child.s_warehouse = source_wh
|
||||
se_child.t_warehouse = target_wh
|
||||
se_child.item_code = cstr(d)
|
||||
|
@ -63,7 +63,8 @@ class DocType(TransactionBase):
|
||||
s_list =[]
|
||||
s_list = self.create_schedule_list(d.start_date, d.end_date, d.no_of_visits)
|
||||
for i in range(d.no_of_visits):
|
||||
child = addchild(self.doc,'maintenance_schedule_detail','Maintenance Schedule Detail',1,self.doclist)
|
||||
child = addchild(self.doc, 'maintenance_schedule_detail',
|
||||
'Maintenance Schedule Detail', self.doclist)
|
||||
child.item_code = d.item_code
|
||||
child.item_name = d.item_name
|
||||
child.scheduled_date = s_list[i].strftime('%Y-%m-%d')
|
||||
|
@ -220,7 +220,7 @@ class TransactionBase:
|
||||
self.doclist = self.doc.clear_table(self.doclist,'sales_team')
|
||||
idx = 0
|
||||
for d in webnotes.conn.sql("select sales_person, allocated_percentage, allocated_amount, incentives from `tabSales Team` where parent = '%s'" % name):
|
||||
ch = addchild(self.doc, 'sales_team', 'Sales Team', 1, self.doclist)
|
||||
ch = addchild(self.doc, 'sales_team', 'Sales Team', self.doclist)
|
||||
ch.sales_person = d and cstr(d[0]) or ''
|
||||
ch.allocated_percentage = d and flt(d[1]) or 0
|
||||
ch.allocated_amount = d and flt(d[2]) or 0
|
||||
|
Loading…
x
Reference in New Issue
Block a user