def apply(self, doc): if self.rule_condition_satisfied(doc): multiplier = 1 points = self.points if self.multiplier_field: multiplier = doc.get(self.multiplier_field) or 1 points = round(points * multiplier) max_points = self.max_points if max_points and points > max_points: points = max_points reference_doctype = doc.doctype reference_name = doc.name users = [] if self.for_assigned_users: users = doc.get_assigned_users() else: users = [doc.get(self.user_field)] rule = self.name # incase of zero as result after roundoff if not points: return try: for user in users: if not user or user == 'Administrator': continue create_energy_points_log(reference_doctype, reference_name, { 'points': points, 'user': user, 'rule': rule }, self.apply_only_once) except Exception as e: frappe.log_error(frappe.get_traceback(), 'apply_energy_point')
def apply(self, doc): if frappe.safe_eval(self.condition, None, {'doc': doc.as_dict()}): multiplier = 1 if self.multiplier_field: multiplier = doc.get(self.multiplier_field) or 1 points = round(self.points * multiplier) reference_doctype = doc.doctype reference_name = doc.name user = doc.get(self.user_field) rule = self.name # incase of zero as result after roundoff if not points: return # if user_field has no value if not user or user == 'Administrator': return try: create_energy_points_log(reference_doctype, reference_name, { 'points': points, 'user': user, 'rule': rule }) except Exception as e: frappe.log_error(frappe.get_traceback(), 'apply_energy_point')
def apply(self, doc): if self.rule_condition_satisfied(doc): multiplier = 1 points = self.points if self.multiplier_field: multiplier = doc.get(self.multiplier_field) or 1 points = round(points * multiplier) max_points = self.max_points if max_points and points > max_points: points = max_points reference_doctype = doc.doctype reference_name = doc.name user = doc.get(self.user_field) rule = self.name # incase of zero as result after roundoff if not points: return # if user_field has no value if not user or user == 'Administrator': return try: create_energy_points_log(reference_doctype, reference_name, { 'points': points, 'user': user, 'rule': rule }) except Exception as e: frappe.log_error(frappe.get_traceback(), 'apply_energy_point')