reload doc in maintenance schedule

This commit is contained in:
Akhilesh Darjee 2014-01-03 19:14:01 +05:30
parent 5c96b75a68
commit 5dd92fd5d6
2 changed files with 28 additions and 9 deletions

View File

@ -5,5 +5,8 @@ from __future__ import unicode_literals
import webnotes
def execute():
webnotes.reload_doc("support", "doctype", "maintenance_schedule_detail")
webnotes.reload_doc("support", "doctype", "maintenance_schedule_item")
webnotes.conn.sql("""update `tabMaintenance Schedule Detail` set sales_person=incharge_name""")
webnotes.conn.sql("""update `tabMaintenance Schedule Item` set sales_person=incharge_name""")

View File

@ -28,9 +28,9 @@ class DocType(TransactionBase):
self.doclist = self.doc.clear_table(self.doclist, 'maintenance_schedule_detail')
webnotes.conn.sql("""delete from `tabMaintenance Schedule Detail`
where parent=%s""", (self.doc.name))
count = 1
for d in getlist(self.doclist, 'item_maintenance_detail'):
self.validate_maintenance_detail()
count = 1
s_list = []
s_list = self.create_schedule_list(d.start_date, d.end_date, d.no_of_visits, d.sales_person)
for i in range(d.no_of_visits):
@ -105,17 +105,33 @@ class DocType(TransactionBase):
return schedule_list
def validate_schedule_date_for_holiday_list(self, schedule_date, sales_person):
from erpnext.accounts.utils import get_fiscal_year
validated = False
fy_details = ""
holiday_list = webnotes.conn.sql_list("""select h.holiday_date from `tabEmployee` emp,
`tabSales Person` sp, `tabHoliday` h where sp.name=%s and emp.name=sp.employee
and h.parent=emp.holiday_list""", sales_person)
try:
fy_details = get_fiscal_year(date=schedule_date, verbose=0)
except Exception:
pass
while not validated:
if schedule_date in holiday_list:
schedule_date = add_days(schedule_date, 1)
else:
validated = True
if fy_details and fy_details[0]:
holiday_list = webnotes.conn.sql_list("""select h.holiday_date from `tabEmployee` emp,
`tabSales Person` sp, `tabHoliday` h, `tabHoliday List` hl
where sp.name=%s and emp.name=sp.employee
and hl.name=emp.holiday_list and
h.parent=hl.name and
hl.fiscal_year=%s""", (sales_person, fy_details[0]))
if not holiday_list:
holiday_list = webnotes.conn.sql("""select h.holiday_date from
`tabHoliday` h, `tabHoliday List` hl
where h.parent=hl.name and ifnull(hl.is_default, 0) = 1
and hl.fiscal_year=%s""", fy_details[0])
while not validated and holiday_list:
if schedule_date in holiday_list:
schedule_date = add_days(schedule_date, -1)
else:
validated = True
return schedule_date