Browse Source

fix: assginment rule only reassign if not assigned

version-14
Rushabh Mehta 6 years ago
parent
commit
f7cf745fb5
4 changed files with 9 additions and 15 deletions
  1. +3
    -3
      frappe/automation/doctype/assignment_rule/assignment_rule.json
  2. +1
    -1
      frappe/automation/doctype/assignment_rule/assignment_rule.py
  3. +1
    -1
      frappe/automation/doctype/assignment_rule/test_assignment_rule.py
  4. +4
    -10
      frappe/desk/form/assign_to.py

+ 3
- 3
frappe/automation/doctype/assignment_rule/assignment_rule.json View File

@@ -217,7 +217,7 @@
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"description": "Example: status == \"Open\"",
"description": "Simple Python Expression, Example: status == 'Open' and type == 'Bug'",
"fieldname": "assign_condition", "fieldname": "assign_condition",
"fieldtype": "Small Text", "fieldtype": "Small Text",
"hidden": 0, "hidden": 0,
@@ -281,7 +281,7 @@
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"description": "Example: Status in (\"Closed\", \"Cancelled\")",
"description": "Simple Python Expression, Example: Status in (\"Closed\", \"Cancelled\")",
"fieldname": "unassign_condition", "fieldname": "unassign_condition",
"fieldtype": "Small Text", "fieldtype": "Small Text",
"hidden": 0, "hidden": 0,
@@ -449,7 +449,7 @@
"issingle": 0, "issingle": 0,
"istable": 0, "istable": 0,
"max_attachments": 0, "max_attachments": 0,
"modified": "2019-02-28 17:12:44.413781",
"modified": "2019-02-28 17:12:44.413782",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Automation", "module": "Automation",
"name": "Assignment Rule", "name": "Assignment Rule",


+ 1
- 1
frappe/automation/doctype/assignment_rule/assignment_rule.py View File

@@ -16,7 +16,7 @@ class AssignmentRule(Document):
frappe.cache().delete_value('assignment_rule') frappe.cache().delete_value('assignment_rule')


def apply(self, doc): def apply(self, doc):
if self.safe_eval('assign_condition', doc):
if not assign_to.get(doc) and self.safe_eval('assign_condition', doc):
self.do_assignment(doc) self.do_assignment(doc)
return True return True




+ 1
- 1
frappe/automation/doctype/assignment_rule/test_assignment_rule.py View File

@@ -130,7 +130,7 @@ def get_assignment_rule():
priority = 0, priority = 0,
document_type = 'Note', document_type = 'Note',
assign_condition = 'public == 1', assign_condition = 'public == 1',
unassign_condition = 'public == 0',
unassign_condition = 'pubic == 0 or notify_on_login == 1',
rule = 'Round Robin', rule = 'Round Robin',
users = [ users = [
dict(user = 'test@example.com'), dict(user = 'test@example.com'),


+ 4
- 10
frappe/desk/form/assign_to.py View File

@@ -6,7 +6,6 @@ from __future__ import unicode_literals


import frappe import frappe
from frappe import _ from frappe import _
from frappe.desk.form.load import get_docinfo
import frappe.share import frappe.share


class DuplicateToDoError(frappe.ValidationError): pass class DuplicateToDoError(frappe.ValidationError): pass
@@ -16,15 +15,10 @@ def get(args=None):
if not args: if not args:
args = frappe.local.form_dict args = frappe.local.form_dict


get_docinfo(frappe.get_doc(args.get("doctype"), args.get("name")))

return frappe.db.sql("""SELECT `owner`, `description`
FROM `tabToDo`
WHERE reference_type=%(doctype)s
AND reference_name=%(name)s
AND status='Open'
ORDER BY modified DESC
LIMIT 5""", args, as_dict=True)
return frappe.get_all('ToDo', fields = ['owner', 'description'], filters = dict(
reference_type = args.get('doctype'),
reference_name = args.get('name')
), limit = 5)


@frappe.whitelist() @frappe.whitelist()
def add(args=None): def add(args=None):


Loading…
Cancel
Save