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