mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-20 13:39:18 +00:00
Small improvement in maintenance scheduler
This improvement is intended to start disable blocking Maintenance Schedule submit, when the `Sales Person` does not have a `user_id` in the Employee! The old logic try to use the `sales_person` email_id or the `owner` to create the event, but due some fails in the code, it dont occurs!
This commit is contained in:
@@ -49,26 +49,28 @@ class MaintenanceSchedule(TransactionBase):
|
|||||||
|
|
||||||
if d.sales_person not in email_map:
|
if d.sales_person not in email_map:
|
||||||
sp = frappe.get_doc("Sales Person", d.sales_person)
|
sp = frappe.get_doc("Sales Person", d.sales_person)
|
||||||
email_map[d.sales_person] = sp.get_email_id()
|
try:
|
||||||
|
email_map[d.sales_person] = sp.get_email_id()
|
||||||
|
except frappe.ValidationError:
|
||||||
|
pass
|
||||||
|
|
||||||
scheduled_date = frappe.db.sql("""select scheduled_date from
|
scheduled_date = frappe.db.sql("""select scheduled_date from
|
||||||
`tabMaintenance Schedule Detail` where sales_person=%s and item_code=%s and
|
`tabMaintenance Schedule Detail` where sales_person=%s and item_code=%s and
|
||||||
parent=%s""", (d.sales_person, d.item_code, self.name), as_dict=1)
|
parent=%s""", (d.sales_person, d.item_code, self.name), as_dict=1)
|
||||||
|
|
||||||
for key in scheduled_date:
|
for key in scheduled_date:
|
||||||
if email_map[d.sales_person]:
|
description = "Reference: %s, Item Code: %s and Customer: %s" % \
|
||||||
description = "Reference: %s, Item Code: %s and Customer: %s" % \
|
(self.name, d.item_code, self.customer)
|
||||||
(self.name, d.item_code, self.customer)
|
frappe.get_doc({
|
||||||
frappe.get_doc({
|
"doctype": "Event",
|
||||||
"doctype": "Event",
|
"owner": email_map.get(d.sales_person, self.owner),
|
||||||
"owner": email_map[d.sales_person] or self.owner,
|
"subject": description,
|
||||||
"subject": description,
|
"description": description,
|
||||||
"description": description,
|
"starts_on": cstr(key["scheduled_date"]) + " 10:00:00",
|
||||||
"starts_on": cstr(key["scheduled_date"]) + " 10:00:00",
|
"event_type": "Private",
|
||||||
"event_type": "Private",
|
"ref_type": self.doctype,
|
||||||
"ref_type": self.doctype,
|
"ref_name": self.name
|
||||||
"ref_name": self.name
|
}).insert(ignore_permissions=1)
|
||||||
}).insert(ignore_permissions=1)
|
|
||||||
|
|
||||||
frappe.db.set(self, 'status', 'Submitted')
|
frappe.db.set(self, 'status', 'Submitted')
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user