Merge pull request #14460 from chdecultot/hotfix_customer
Customer timeline data hotfix
diff --git a/erpnext/accounts/party.py b/erpnext/accounts/party.py
index f6fc0bb..8ab25a3 100644
--- a/erpnext/accounts/party.py
+++ b/erpnext/accounts/party.py
@@ -414,7 +414,7 @@
# fetch and append data from Activity Log
data += frappe.db.sql("""select {fields}
from `tabActivity Log`
- where reference_doctype='{doctype}' and reference_name='{name}'
+ where reference_doctype="{doctype}" and reference_name="{name}"
and status!='Success' and creation > {after}
{group_by} order by creation desc
""".format(doctype=frappe.db.escape(doctype), name=frappe.db.escape(name), fields=fields,
diff --git a/erpnext/hr/doctype/leave_application/leave_application.py b/erpnext/hr/doctype/leave_application/leave_application.py
index e03764a..eb5aec6 100755
--- a/erpnext/hr/doctype/leave_application/leave_application.py
+++ b/erpnext/hr/doctype/leave_application/leave_application.py
@@ -60,6 +60,7 @@
def on_cancel(self):
# notify leave applier about cancellation
self.notify_employee("cancelled")
+ self.cancel_attendance()
def validate_dates(self):
if self.from_date and self.to_date and (getdate(self.to_date) < getdate(self.from_date)):
@@ -138,6 +139,13 @@
doc.insert(ignore_permissions=True)
doc.submit()
+ def cancel_attendance(self):
+ if self.docstatus == 2:
+ attendance = frappe.db.sql("""select name from `tabAttendance` where employee = %s\
+ and (attendance_date between %s and %s) and docstatus < 2 and status in ('On Leave', 'Half Day')""",(self.employee, self.from_date, self.to_date), as_dict=1)
+ for name in attendance:
+ frappe.db.set_value("Attendance", name, "docstatus", 2)
+
def validate_salary_processed_days(self):
if not frappe.db.get_value("Leave Type", self.leave_type, "is_lwp"):
return
diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.py b/erpnext/stock/doctype/stock_entry/stock_entry.py
index d1dcb31..5ed8ada 100644
--- a/erpnext/stock/doctype/stock_entry/stock_entry.py
+++ b/erpnext/stock/doctype/stock_entry/stock_entry.py
@@ -263,7 +263,7 @@
d.actual_qty = previous_sle.get("qty_after_transaction") or 0
# validate qty during submit
- if d.docstatus==1 and d.s_warehouse and not allow_negative_stock and d.actual_qty < d.transfer_qty:
+ if d.docstatus==1 and d.s_warehouse and not allow_negative_stock and flt(d.actual_qty, d.precision("actual_qty")) < flt(d.transfer_qty, d.precision("actual_qty")):
frappe.throw(_("Row {0}: Qty not available for {4} in warehouse {1} at posting time of the entry ({2} {3})").format(d.idx,
frappe.bold(d.s_warehouse), formatdate(self.posting_date),
format_time(self.posting_time), frappe.bold(d.item_code))