Merge branch 'master' of github.com:webnotes/erpnext

Conflicts:
	patches/patch.py
This commit is contained in:
Anand Doshi 2011-08-10 11:23:31 +05:30
commit d78b8b5337
13 changed files with 681 additions and 670 deletions

View File

@ -455,7 +455,8 @@
'description': "Don't delete this field at any cost",
'doctype': 'DocField',
'fieldname': 'old_parent',
'fieldtype': 'Data',
'fieldtype': 'Link',
'options': 'Account',
'hidden': 1,
'idx': 24,
'label': 'Old Parent',

View File

@ -51,7 +51,6 @@ for r in res:
q1 = "select sum(t1.budget_allocated) from `tabBudget Detail` t1, `tab%s` t2, `tabAccount` t3 where "
cond2 = " t3.is_pl_account = 'Yes' and t3.debit_or_credit = 'Debit' and t3.name = t1.account and t1.docstatus != 2 and "
if ch:
qur = q1+cond2+cond1+" and t2.name = '%s'"
ret_amt = sql(qur%(based_on,fiscal_year,based_on,r[0].strip()))

View File

@ -52,12 +52,12 @@ cur_frm.cscript.from_date = function(doc, dt, dn) {
// to date
// --------
cur_frm.cscript.to_date = function(doc, dt, dn) {
if(cint(doc.half_day) == 1 && doc.from_date && doc.from_date != doc.to_date){
if(cint(doc.half_day) == 1 && cstr(doc.from_date) && doc.from_date != doc.to_date){
msgprint("To Date should be same as From Date for Half Day leave");
return;
set_multiple(dt,dn,{to_date:doc.from_date});
}
if(cint(doc.half_day) == 1){
set_multiple(dt,dn,{to_date:doc.from_date});
}
calculate_total_days(doc, dt, dn);
}

View File

@ -29,7 +29,7 @@ cur_frm.cscript.month = cur_frm.cscript.employee = cur_frm.cscript.fiscal_year;
// Calculate total if lwp exists
// ------------------------------------------------------------------------
cur_frm.cscript.leave_without_pay = function(doc,dt,dn){
doc.payment_days = cint(doc.total_days_in_month) - cint(doc.leave_without_pay);
doc.payment_days = flt(doc.total_days_in_month) - flt(doc.leave_without_pay);
refresh_field('payment_days');
calculate_all(doc, dt, dn);
}

View File

@ -101,8 +101,17 @@ class DocType(TransactionBase):
for d in range(m[3]):
dt = add_days(cstr(m[1]), d)
if dt not in holidays:
if sql("select t1.name from `tabLeave Application` t1, `tabLeave Type` t2 where t2.name = t1.leave_type and ifnull(t2.is_lwp, 0) = 1 and t1.docstatus = 1 and t1.employee = '%s' and '%s' between from_date and to_date"%(self.doc.employee, dt)):
lwp += 1
leave = sql("""
select t1.name, t1.half_day
from `tabLeave Application` t1, `tabLeave Type` t2
where t2.name = t1.leave_type
and ifnull(t2.is_lwp, 0) = 1
and t1.docstatus = 1
and t1.employee = '%s'
and '%s' between from_date and to_date
"""%(self.doc.employee, dt))
if leave:
lwp = cint(leave[0][1]) and lwp + 0.5 or lwp + 1
return lwp
# Check existing

View File

@ -1,7 +1,7 @@
# REMEMBER to update this
# ========================
last_patch = 332
last_patch = 335
#-------------------------------------------
@ -56,7 +56,8 @@ def execute(patch_no):
pass
elif patch_no == 40:
import_from_files(record_list=[['stock','doctype','item']])
import_from_files(record_list=[['material_management','doctype','item']])
elif patch_no == 42:
acc = sql("select name, lft, rgt from tabAccount where account_name in ('Incomes', 'Expenses')")
for d in acc:
@ -125,6 +126,7 @@ def execute(patch_no):
sql("delete from `tabModule Def Item` where parent = 'CRM' and doc_type = 'Reports' and doc_name = 'Delivery Note' and display_name = 'Territory, Item Group wise GP'")
elif patch_no == 57:
import_from_files(record_list=[['selling','doctype','sales_order_detail']])
elif patch_no == 58:
# module def patches
sql("update `tabModule Def` set module_page = NULL where name not in ('Event Updates', 'Setup', 'My Company')")
@ -158,7 +160,8 @@ def execute(patch_no):
sql("delete from `tabTDS Category Account` where company not in (select name from tabCompany)")
elif patch_no == 62:
# Import Supplier Quotation
import_from_files(record_list=[['buying','doctype','supplier_quotation']])
import_from_files(record_list=[['srm','doctype','supplier_quotation']])
# Adding Status Filter
sql("update tabDocType set search_fields = concat('status,',search_fields) where name IN ('Delivery Note','Leave Transaction')")
# Import Other Charges
@ -166,7 +169,8 @@ def execute(patch_no):
import_from_files(record_list=[['setup','doctype','other_charges']])
elif patch_no == 63:
sql("update `tabDocField` set permlevel = 1 where fieldname in ('return_date', 'return_details') and parent = 'Sales and Purchase Return Wizard'")
import_from_files(record_list = [['accounts', 'doctype', 'rv_detail'], ['stock', 'doctype', 'sales_and_purchase_return_wizard'], ['stock', 'doctype', 'stock_entry']])
import_from_files(record_list = [['accounts', 'doctype', 'rv_detail'], ['material_management', 'doctype', 'sales_and_purchase_return_wizard'], ['material_management', 'doctype', 'stock_entry']])
elif patch_no == 64:
sql("update tabDocField set `hidden` = 1, `print_hide` = 1, `report_hide` = 1 where options in ('RFQ','Supplier Quotation')")
sql("update tabDocType set `read_only` = 1, in_create = 1 where name in ('RFQ','Supplier Quotation')")
@ -347,7 +351,7 @@ def execute(patch_no):
p.add_permission('Salary Slip', 'Employee', 1, read = 1, match = 'owner')
elif patch_no == 79:
# Import Modules
import_from_files(record_list=[['hr','doctype','leave_application'],['hr','doctype','leave_allocation'],['hr','doctype','leave_control_panel'],['hr','doctype','holiday_list'],['hr','doctype','holiday_list_detail'],['hr','Module Def','Payroll']])
import_from_files(record_list=[['hr','doctype','leave_application'],['hr','doctype','leave_allocation'],['hr','doctype','leave_control_panel'],['hr','doctype','holiday_list'],['hr','doctype','holiday_list_detail'],['hr','Module Def','HR']])
elif patch_no == 80:
# Holiday List
sql("update `tabHoliday List Detail` set description = holiday_name")
@ -400,7 +404,7 @@ def execute(patch_no):
elif patch_no == 81:
# Import Modules
import_from_files(record_list=[['hr','Module Def','Payroll']])
import_from_files(record_list=[['hr','Module Def','HR']])
elif patch_no == 82:
sql("update tabDocType set search_fields = 'employee,leave_type,total_leaves_allocated,fiscal_year' where name = 'Leave Allocation'")
sql("update tabDocType set search_fields = 'employee,leave_type,from_date,to_date,total_leave_days,fiscal_year' where name = 'Leave Application'")
@ -432,6 +436,7 @@ def execute(patch_no):
elif patch_no == 88:
# Import Modules
import_from_files(record_list=[['hr','doctype','leave_allocation']])
elif patch_no == 89:
sql("delete from `tabModule Def Item` where doc_type = 'Setup Forms' and doc_name in ('Payroll Rule', 'IT Checklist', 'Employee Profile') and parent = 'Payroll'")
sql("update `tabDocField` set `hidden` = 1, `print_hide` = 1, `report_hide` = 1 where parent = 'Leave Type' and fieldname = 'is_encash'")
@ -480,7 +485,8 @@ def execute(patch_no):
elif patch_no == 103:
sql("update tabDocField set fieldname = '' where fieldtype = 'HTML'")
elif patch_no == 104:
import_from_files(record_list=[['hr','search_criteria','stdsrch_00001'],['hr','search_criteria','stdsrch_00002'],['hr','search_criteria','stdsrch_00003'],['hr','Module Def','Payroll'],['hr','doctype','leave_application'],['hr','doctype','leave_allocation']])
import_from_files(record_list=[['hr','search_criteria','stdsrch_00001'],['hr','search_criteria','stdsrch_00002'],['hr','search_criteria','stdsrch_00003'],['hr','Module Def','HR'],['hr','doctype','leave_application'],['hr','doctype','leave_allocation']])
elif patch_no == 105:
# Employee Leave Balance
sql("delete from `tabModule Def Item` where parent = 'Payroll' and doc_type = 'Reports' and display_name IN ('Employeewise Leave Transaction Details','Employeewise Balance Leave Report')")
@ -941,6 +947,7 @@ def execute(patch_no):
reload_doc('core', 'doctype', 'docfield')
reload_doc('core', 'doctype', 'doctype')
from patches.old_patches.feed_patch import set_subjects_and_tagfields
set_subjects_and_tagfields()
elif patch_no == 240:
# again for sales order (status)
@ -1336,3 +1343,15 @@ def execute(patch_no):
p.add_permission('Lease Agreement', 'Accounts Manager', 1, read = 1)
elif patch_no == 332:
sql("update `tabDocField` set permlevel=1, hidden = 1 where parent = 'Bulk Rename Tool' and fieldname = 'file_list'")
elif patch_no == 333:
sql("update `tabDocPerm` set create =1 where role = 'Accounts Manager' and parent = 'Lease Agreement'")
p = get_obj('Patch Util')
p.add_permission('DocType Mapper', 'System Manager', 0, read = 1, write=1, create=1)
p.add_permission('Role', 'System Manager', 0, read = 1, write=1, create=1)
p.add_permission('Print Format', 'System Manager', 0, read = 1, write=1, create=1)
elif patch_no == 334:
reload_doc('knowledge_base', 'doctype', 'answer')
elif patch_no == 335:
for dt in ['Account', 'Cost Center', 'Territory', 'Item Group', 'Customer Group']:
sql("update `tabDocField` set fieldtype = 'Link', options = %s where fieldname = 'old_parent' and parent = %s", (dt, dt))

View File

@ -329,6 +329,28 @@ class DocType(TransactionBase):
il.append([warehouse, d.item_code, qty, reserved_qty, d.stock_uom, d.batch_no, d.serial_no])
return il
# ---------------------------------------------------------------------------------------------
# get qty, amount already billed or delivered against curr line item for current doctype
# For Eg: SO-RV get total qty, amount from SO and also total qty, amount against that SO in RV
# ---------------------------------------------------------------------------------------------
def get_curr_and_ref_doc_details(self, curr_doctype, ref_tab_fname, ref_tab_dn, ref_doc_tname, curr_parent_name, curr_parent_doctype):
# Get total qty, amt of current doctype (eg RV) except for qty, amt of this transaction
if curr_parent_doctype == 'Installation Note':
curr_det = sql("select sum(qty) from `tab%s` where %s = '%s' and docstatus = 1 and parent != '%s'"% (curr_doctype, ref_tab_fname, ref_tab_dn, curr_parent_name))
qty, amt = curr_det and flt(curr_det[0][0]) or 0, 0
else:
curr_det = sql("select sum(qty), sum(amount) from `tab%s` where %s = '%s' and docstatus = 1 and parent != '%s'"% (curr_doctype, ref_tab_fname, ref_tab_dn, curr_parent_name))
qty, amt = curr_det and flt(curr_det[0][0]) or 0, curr_det and flt(curr_det[0][1]) or 0
# get total qty of ref doctype
ref_det = sql("select qty, amount from `tab%s` where name = '%s' and docstatus = 1"% (ref_doc_tname, ref_tab_dn))
max_qty, max_amt = ref_det and flt(ref_det[0][0]) or 0, ref_det and flt(ref_det[0][1]) or 0
return qty, max_qty, amt, max_amt
# -----------------------
# add packing list items
@ -458,26 +480,6 @@ class DocType(TransactionBase):
def update_prevdoc_detail(self, is_submit, obj):
StatusUpdater(obj, is_submit).update()
# ---------------------------------------------------------------------------------------------
# get qty, amount already billed or delivered against curr line item for current doctype
# For Eg: SO-RV get total qty, amount from SO and also total qty, amount against that SO in RV
# ---------------------------------------------------------------------------------------------
def get_curr_and_ref_doc_details(self, curr_doctype, ref_tab_fname, ref_tab_dn, ref_doc_tname, curr_parent_name, curr_parent_doctype):
# Get total qty, amt of current doctype (eg RV) except for qty, amt of this transaction
if curr_parent_doctype == 'Installation Note':
curr_det = sql("select sum(qty) from `tab%s` where %s = '%s' and docstatus = 1 and parent != '%s'"% (curr_doctype, ref_tab_fname, ref_tab_dn, curr_parent_name))
qty, amt = curr_det and flt(curr_det[0][0]) or 0, 0
else:
curr_det = sql("select sum(qty), sum(amount) from `tab%s` where %s = '%s' and docstatus = 1 and parent != '%s'"% (curr_doctype, ref_tab_fname, ref_tab_dn, curr_parent_name))
qty, amt = curr_det and flt(curr_det[0][0]) or 0, curr_det and flt(curr_det[0][1]) or 0
# get total qty of ref doctype
ref_det = sql("select qty, amount from `tab%s` where name = '%s' and docstatus = 1"% (ref_doc_tname, ref_tab_dn))
max_qty, max_amt = ref_det and flt(ref_det[0][0]) or 0, ref_det and flt(ref_det[0][1]) or 0
return qty, max_qty, amt, max_amt

View File

@ -1,25 +0,0 @@
import unittest
import webnotes
from webnotes.model.code import get_obj
class SubmissionTest(unittest.TestCase):
def setUp(self):
self.dn = webnotes.testing.create('Delivery Note')
self.dn_items = []
# get a line item for testing
for d in self.dn.doclist:
if d.doctype=='Delivery Note Detail':
self.dn_items.append(d)
self.old_bin = get_obj('Warehouse', self.line_item[0].warehouse).get_bin(self.line_item[0].item_code)
self.dn.on_submit()
def test_bin_is_updated(self):
"tests if bin quantity is affected when on submission"
bin = get_obj('Warehouse', self.line_item.warehouse).get_bin(self.line_item[0].item_code)
self.assertTrue(bin.actual_qty == self.old_bin.actual_qty - self.line_item[0].qty)
def test_sales_order_is_updated(self):
"tests if"

View File

@ -178,3 +178,7 @@ Total Available Qty: %s
sle = sql("select name from `tabStock Ledger Entry` where item_code = %s and ifnull(is_cancelled, 'No') = 'No'", self.doc.name)
return sle and 'exists' or 'not exists'
def on_rename(self,newdn,olddn):
sql("update tabItem set item_code = %s where name = %s", (newdn, olddn))

View File

@ -253,7 +253,8 @@
'no_copy': 1,
'oldfieldname': 'serial_no',
'oldfieldtype': 'Text',
'permlevel': 0
'permlevel': 0,
'reqd': 0
},
# DocField

View File

@ -3,9 +3,9 @@
# These values are common in all dictionaries
{
'creation': '2011-07-07 17:47:52',
'creation': '2011-07-08 11:14:15',
'docstatus': 0,
'modified': '2011-07-27 13:19:22',
'modified': '2011-07-26 00:59:27',
'modified_by': 'Administrator',
'owner': 'Administrator'
},

View File

@ -86,6 +86,7 @@ class DocType:
d.parenttype = 'DocType'
d.parentfield = 'permissions'
d.level = level
d.role = role
d.read = read
d.write = write