fix(delivery): Add more context for dispatch notification email + formatting fixes
This commit is contained in:
parent
2e98da8bfe
commit
4babfdb987
@ -20,8 +20,7 @@ class DeliveryTrip(Document):
|
|||||||
# Google Maps returns distances in meters by default
|
# Google Maps returns distances in meters by default
|
||||||
self.default_distance_uom = frappe.db.get_single_value("Global Defaults", "default_distance_unit") or "Meter"
|
self.default_distance_uom = frappe.db.get_single_value("Global Defaults", "default_distance_unit") or "Meter"
|
||||||
self.uom_conversion_factor = frappe.db.get_value("UOM Conversion Factor",
|
self.uom_conversion_factor = frappe.db.get_value("UOM Conversion Factor",
|
||||||
{"from_uom": "Meter", "to_uom": self.default_distance_uom},
|
{"from_uom": "Meter", "to_uom": self.default_distance_uom}, "value")
|
||||||
"value")
|
|
||||||
|
|
||||||
def validate(self):
|
def validate(self):
|
||||||
self.validate_stop_addresses()
|
self.validate_stop_addresses()
|
||||||
@ -358,8 +357,12 @@ def notify_customers(delivery_trip):
|
|||||||
email_recipients = []
|
email_recipients = []
|
||||||
|
|
||||||
for stop in delivery_trip.delivery_stops:
|
for stop in delivery_trip.delivery_stops:
|
||||||
contact_info = frappe.db.get_value("Contact", stop.contact,
|
contact_info = frappe.db.get_value("Contact", stop.contact, ["first_name", "last_name", "email_id"], as_dict=1)
|
||||||
["first_name", "last_name", "email_id", "gender"], as_dict=1)
|
|
||||||
|
context.update({"items": []})
|
||||||
|
if stop.delivery_note:
|
||||||
|
items = frappe.get_all("Delivery Note Item", filters={"parent": stop.delivery_note, "docstatus": 1}, fields=["*"])
|
||||||
|
context.update({"items": items})
|
||||||
|
|
||||||
if contact_info and contact_info.email_id:
|
if contact_info and contact_info.email_id:
|
||||||
context.update(stop.as_dict())
|
context.update(stop.as_dict())
|
||||||
@ -388,9 +391,7 @@ def get_attachments(delivery_stop):
|
|||||||
return []
|
return []
|
||||||
|
|
||||||
dispatch_attachment = frappe.db.get_single_value("Delivery Settings", "dispatch_attachment")
|
dispatch_attachment = frappe.db.get_single_value("Delivery Settings", "dispatch_attachment")
|
||||||
attachments = frappe.attach_print("Delivery Note",
|
attachments = frappe.attach_print("Delivery Note", delivery_stop.delivery_note,
|
||||||
delivery_stop.delivery_note,
|
file_name="Delivery Note", print_format=dispatch_attachment)
|
||||||
file_name="Delivery Note",
|
|
||||||
print_format=dispatch_attachment)
|
|
||||||
|
|
||||||
return [attachments]
|
return [attachments]
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user