Patch fixed for v6 to v7 migration
This commit is contained in:
parent
0c1be8df35
commit
613ef344f3
@ -1,23 +1,30 @@
|
||||
import frappe
|
||||
from erpnext.manufacturing.doctype.production_order.production_order \
|
||||
import make_timesheet, add_timesheet_detail
|
||||
from erpnext.projects.doctype.timesheet.timesheet import OverlapError
|
||||
|
||||
def execute():
|
||||
frappe.reload_doc('projects', 'doctype', 'timesheet')
|
||||
|
||||
for data in frappe.get_all('Time Log', fields=["*"], filters = [["docstatus", "<", "2"]]):
|
||||
try:
|
||||
time_sheet = make_timesheet(data.production_order)
|
||||
args = get_timelog_data(data)
|
||||
add_timesheet_detail(time_sheet, args)
|
||||
time_sheet.docstatus = data.docstatus
|
||||
time_sheet.note = data.note
|
||||
time_sheet.company = frappe.db.get_single_value('Global Defaults', 'default_company')
|
||||
time_sheet.save(ignore_permissions=True)
|
||||
except OverlapError:
|
||||
time_sheet.flags.ignore_validate = True
|
||||
time_sheet.save(ignore_permissions=True)
|
||||
if data.task:
|
||||
company = frappe.db.get_value("Task", data.task, "company")
|
||||
elif data.production_order:
|
||||
company = frappe.db.get_value("Prodction Order", data.production_order, "company")
|
||||
else:
|
||||
company = frappe.db.get_single_value('Global Defaults', 'default_company')
|
||||
|
||||
time_sheet = make_timesheet(data.production_order)
|
||||
args = get_timelog_data(data)
|
||||
add_timesheet_detail(time_sheet, args)
|
||||
time_sheet.docstatus = data.docstatus
|
||||
time_sheet.note = data.note
|
||||
time_sheet.company = company
|
||||
|
||||
time_sheet.set_status()
|
||||
time_sheet.update_cost()
|
||||
time_sheet.calculate_total_amounts()
|
||||
time_sheet.flags.ignore_validate = True
|
||||
time_sheet.save(ignore_permissions=True)
|
||||
|
||||
def get_timelog_data(data):
|
||||
return {
|
||||
|
@ -2,19 +2,25 @@ from __future__ import unicode_literals
|
||||
import frappe
|
||||
|
||||
def execute():
|
||||
if frappe.db.exists("DocType", "Student") and "father_name" in frappe.db.get_table_columns("Student"):
|
||||
frappe.reload_doc("schools", "doctype", "student")
|
||||
frappe.reload_doc("schools", "doctype", "guardian")
|
||||
frappe.reload_doc("schools", "doctype", "guardian_interest")
|
||||
frappe.reload_doc("hr", "doctype", "interest")
|
||||
if frappe.db.exists("DocType", "Student"):
|
||||
student_table_cols = frappe.db.get_table_columns("Student")
|
||||
if "father_name" in student_table_cols:
|
||||
frappe.reload_doc("schools", "doctype", "student")
|
||||
frappe.reload_doc("schools", "doctype", "guardian")
|
||||
frappe.reload_doc("schools", "doctype", "guardian_interest")
|
||||
frappe.reload_doc("hr", "doctype", "interest")
|
||||
|
||||
fields = ["name", "father_name", "mother_name"]
|
||||
|
||||
if "father_email_id" in student_table_cols:
|
||||
fields += ["father_email_id", "mother_email_id"]
|
||||
|
||||
students = frappe.get_all("Student", fields=["name", "father_name", "father_email_id",
|
||||
"mother_name", "mother_email_id"])
|
||||
for stud in students:
|
||||
if stud.father_name:
|
||||
make_guardian(stud.father_name, stud.name, stud.father_email_id)
|
||||
if stud.mother_name:
|
||||
make_guardian(stud.mother_name, stud.name, stud.mother_email_id)
|
||||
students = frappe.get_all("Student", fields)
|
||||
for stud in students:
|
||||
if stud.father_name:
|
||||
make_guardian(stud.father_name, stud.name, stud.father_email_id)
|
||||
if stud.mother_name:
|
||||
make_guardian(stud.mother_name, stud.name, stud.mother_email_id)
|
||||
|
||||
def make_guardian(name, student, email=None):
|
||||
frappe.get_doc({
|
||||
|
@ -1,5 +1,6 @@
|
||||
from __future__ import unicode_literals
|
||||
import frappe, os
|
||||
from frappe.installer import remove_from_installed_apps
|
||||
|
||||
def execute():
|
||||
reload_doctypes_for_schools_icons()
|
||||
@ -10,18 +11,15 @@ def execute():
|
||||
|
||||
if 'schools' in frappe.get_installed_apps():
|
||||
frappe.db.sql("""delete from `tabDesktop Icon`""")
|
||||
if not frappe.db.exists('Module Def', 'Schools'):
|
||||
frappe.get_doc({
|
||||
'doctype': 'Module Def',
|
||||
'module_name': 'Schools',
|
||||
'app_name': 'erpnext'
|
||||
}).insert()
|
||||
frappe.db.sql("""update `tabDocType` set module='Schools' where module='Academics'""")
|
||||
from frappe.installer import remove_from_installed_apps
|
||||
|
||||
if not frappe.db.exists('Module Def', 'Schools') and frappe.db.exists('Module Def', 'Academics'):
|
||||
frappe.rename_doc("Module Def", "Academics", "Schools")
|
||||
|
||||
remove_from_installed_apps("schools")
|
||||
|
||||
def reload_doctypes_for_schools_icons():
|
||||
base_path = frappe.get_app_path('erpnext', 'schools', 'doctype')
|
||||
for doctype in os.listdir(base_path):
|
||||
if os.path.exists(os.path.join(base_path, doctype, doctype + '.json')):
|
||||
frappe.reload_doc('schools', 'doctype', doctype)
|
||||
if os.path.exists(os.path.join(base_path, doctype, doctype + '.json')) \
|
||||
and doctype not in ("fee_component", "assessment", "assessment_result"):
|
||||
frappe.reload_doc('schools', 'doctype', doctype)
|
@ -9,7 +9,9 @@ from frappe.model.utils.rename_field import rename_field
|
||||
def execute():
|
||||
if frappe.db.exists("DocType", "Examination"):
|
||||
frappe.rename_doc("DocType", "Examination", "Assessment")
|
||||
frappe.reload_doctype("Assessment")
|
||||
frappe.rename_doc("DocType", "Examination Result", "Assessment Result")
|
||||
frappe.reload_doc("schools", "doctype", "assessment")
|
||||
frappe.reload_doc("schools", "doctype", "assessment_result")
|
||||
rename_field("Assessment", "exam_name", "assessment_name")
|
||||
rename_field("Assessment", "exam_code", "assessment_code")
|
||||
|
||||
|
@ -159,8 +159,8 @@ class Timesheet(Document):
|
||||
|
||||
existing = self.get_overlap_for(fieldname, args, value)
|
||||
if existing:
|
||||
frappe.throw(_("Row {0}: From Time and To Time overlap with existing from and to time").format(args.idx),
|
||||
OverlapError)
|
||||
frappe.throw(_("Row {0}: From Time and To Time of {1} is overlapping with {2}")
|
||||
.format(args.idx, self.name, existing.name), OverlapError)
|
||||
|
||||
def get_overlap_for(self, fieldname, args, value):
|
||||
cond = "ts.`{0}`".format(fieldname)
|
||||
|
Loading…
x
Reference in New Issue
Block a user