fix: Show assignments based on allocated todo only

This commit is contained in:
Nabin Hait 2022-02-16 18:14:49 +05:30
parent cd8bd4ccf0
commit 762aeb32f0
4 changed files with 15 additions and 2 deletions

View file

@ -72,7 +72,8 @@ class ToDo(Document):
assignments = frappe.get_all("ToDo", filters={
"reference_type": self.reference_type,
"reference_name": self.reference_name,
"status": ("!=", "Cancelled")
"status": ("!=", "Cancelled"),
"allocated_to": ("is", "set")
}, pluck="allocated_to")
assignments.reverse()

View file

@ -312,6 +312,7 @@ def get_assignments(dt, dn):
'reference_type': dt,
'reference_name': dn,
'status': ('!=', 'Cancelled'),
'allocated_to': ("is", "set")
})
@frappe.whitelist()

View file

@ -111,7 +111,6 @@ class EmailQueue(Document):
""" Send emails to recipients.
"""
if not self.can_send_now():
frappe.db.rollback()
return
with SendMailContext(self, is_background_task) as ctx:

View file

@ -4,6 +4,7 @@ import frappe, unittest
import frappe.desk.form.assign_to
from frappe.desk.listview import get_group_by_count
from frappe.automation.doctype.assignment_rule.test_assignment_rule import make_note
from frappe.desk.form.load import get_assignments
class TestAssign(unittest.TestCase):
def test_assign(self):
@ -55,6 +56,17 @@ class TestAssign(unittest.TestCase):
frappe.db.rollback()
def test_assignment_removal(self):
todo = frappe.get_doc({"doctype":"ToDo", "description": "test"}).insert()
if not frappe.db.exists("User", "test@example.com"):
frappe.get_doc({"doctype":"User", "email":"test@example.com", "first_name":"Test"}).insert()
new_todo = assign(todo, "test@example.com")
# remove assignment
frappe.db.set_value("ToDo", new_todo[0].name, "allocated_to", "")
self.assertFalse(get_assignments("ToDo", todo.name))
def assign(doc, user):
return frappe.desk.form.assign_to.add({