fix: review points when added more then once. (#23239)

* fix: review points when added more then once.

previously when user added review more then once it didn't work properly
because of apply_only_once check which is only meant for rule based points
changed that behaviour to only check when called from energy_point_rule by checking if doc.rule is set.
This commit is contained in:
Maharshi Patel 2023-11-22 12:31:35 +05:30 committed by GitHub
parent a4cbe36cbe
commit 83f2227cdb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -189,13 +189,12 @@ def get_alert_dict(doc):
def create_energy_points_log(ref_doctype, ref_name, doc, apply_only_once=False):
doc = frappe._dict(doc)
log_exists = check_if_log_exists(
ref_doctype, ref_name, doc.rule, None if apply_only_once else doc.user
)
if log_exists:
return frappe.get_doc("Energy Point Log", log_exists)
if doc.rule:
log_exists = check_if_log_exists(
ref_doctype, ref_name, doc.rule, None if apply_only_once else doc.user
)
if log_exists:
return frappe.get_doc("Energy Point Log", log_exists)
new_log = frappe.new_doc("Energy Point Log")
new_log.reference_doctype = ref_doctype