feat: assignment rule days
This commit is contained in:
parent
7b93d6ea33
commit
19ff2489f1
5 changed files with 69 additions and 1 deletions
|
|
@ -18,6 +18,8 @@
|
|||
"unassign_condition",
|
||||
"section_break_10",
|
||||
"close_condition",
|
||||
"sb",
|
||||
"assignment_day",
|
||||
"assign_to_users_section",
|
||||
"rule",
|
||||
"users",
|
||||
|
|
@ -115,9 +117,20 @@
|
|||
"fieldname": "close_condition",
|
||||
"fieldtype": "Code",
|
||||
"label": "Close Condition"
|
||||
},
|
||||
{
|
||||
"fieldname": "sb",
|
||||
"fieldtype": "Section Break",
|
||||
"label": "Assignment Days"
|
||||
},
|
||||
{
|
||||
"fieldname": "assignment_day",
|
||||
"fieldtype": "Table",
|
||||
"label": "Assignment Days",
|
||||
"options": "Assignment Rule Day"
|
||||
}
|
||||
],
|
||||
"modified": "2019-09-10 14:45:53.657667",
|
||||
"modified": "2019-09-21 16:54:10.370154",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Automation",
|
||||
"name": "Assignment Rule",
|
||||
|
|
|
|||
|
|
@ -118,6 +118,9 @@ class AssignmentRule(Document):
|
|||
|
||||
return False
|
||||
|
||||
def get_assignment_days(self):
|
||||
return [d.day for d in self.assignment_days]
|
||||
|
||||
def get_assignments(doc):
|
||||
return frappe.get_all('ToDo', fields = ['name', 'assignment_rule'], filters = dict(
|
||||
reference_type = doc.get('doctype'),
|
||||
|
|
@ -175,12 +178,18 @@ def apply(doc, method=None, doctype=None, name=None):
|
|||
clear = True # are all assignments cleared
|
||||
new_apply = False # are new assignments applied
|
||||
|
||||
today = frappe.utils.get_weekday()
|
||||
|
||||
if assignments:
|
||||
# first unassign
|
||||
# use case, there are separate groups to be assigned for say L1 and L2,
|
||||
# so when the value switches from L1 to L2, L1 team must be unassigned, then L2 can be assigned.
|
||||
clear = False
|
||||
for assignment_rule in assignment_rule_docs:
|
||||
assignment_rule_days = assignment_rule.get_assignment_days()
|
||||
if assignment_rule_days and not today in assignment_rule_days:
|
||||
continue
|
||||
|
||||
clear = assignment_rule.apply_unassign(doc, assignments)
|
||||
if clear:
|
||||
break
|
||||
|
|
@ -188,6 +197,10 @@ def apply(doc, method=None, doctype=None, name=None):
|
|||
# apply rule only if there are no existing assignments
|
||||
if clear:
|
||||
for assignment_rule in assignment_rule_docs:
|
||||
assignment_rule_days = assignment_rule.get_assignment_days()
|
||||
if assignment_rule_days and not today in assignment_rule_days:
|
||||
continue
|
||||
|
||||
new_apply = assignment_rule.apply_assign(doc)
|
||||
if new_apply:
|
||||
break
|
||||
|
|
@ -196,6 +209,10 @@ def apply(doc, method=None, doctype=None, name=None):
|
|||
assignments = get_assignments(doc)
|
||||
if assignments:
|
||||
for assignment_rule in assignment_rule_docs:
|
||||
assignment_rule_days = assignment_rule.get_assignment_days()
|
||||
if assignment_rule_days and not today in assignment_rule_days:
|
||||
continue
|
||||
|
||||
if not new_apply:
|
||||
reopen = reopen_closed_assignment(doc)
|
||||
if reopen:
|
||||
|
|
|
|||
|
|
@ -0,0 +1,28 @@
|
|||
{
|
||||
"creation": "2019-09-21 16:52:01.705351",
|
||||
"doctype": "DocType",
|
||||
"editable_grid": 1,
|
||||
"engine": "InnoDB",
|
||||
"field_order": [
|
||||
"day"
|
||||
],
|
||||
"fields": [
|
||||
{
|
||||
"fieldname": "day",
|
||||
"fieldtype": "Select",
|
||||
"in_list_view": 1,
|
||||
"label": "Day",
|
||||
"options": "Monday\nTuesday\nWednesday\nThursday\nFriday\nSaturday\nSunday"
|
||||
}
|
||||
],
|
||||
"istable": 1,
|
||||
"modified": "2019-09-21 16:55:09.376291",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Automation",
|
||||
"name": "Assignment Rule Day",
|
||||
"owner": "Administrator",
|
||||
"permissions": [],
|
||||
"sort_field": "modified",
|
||||
"sort_order": "DESC",
|
||||
"track_changes": 1
|
||||
}
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Copyright (c) 2019, Frappe Technologies and contributors
|
||||
# For license information, please see license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
# import frappe
|
||||
from frappe.model.document import Document
|
||||
|
||||
class AssignmentRuleDay(Document):
|
||||
pass
|
||||
Loading…
Add table
Reference in a new issue