fix(minor): minor fixes in document_naming.py and mandatory

This commit is contained in:
Rushabh Mehta 2020-11-04 15:01:32 +05:30
parent 313aad91f3
commit ebf696c8c8
2 changed files with 7 additions and 5 deletions

View file

@ -34,7 +34,8 @@
"fieldname": "prefix",
"fieldtype": "Data",
"label": "Prefix",
"mandatory_depends_on": "eval:doc.naming_by===\"Numbered\""
"mandatory_depends_on": "eval:doc.naming_by===\"Numbered\"",
"reqd": 1
},
{
"fieldname": "counter",
@ -48,7 +49,8 @@
"fieldname": "prefix_digits",
"fieldtype": "Int",
"label": "Digits",
"mandatory_depends_on": "eval:doc.naming_by===\"Numbered\""
"mandatory_depends_on": "eval:doc.naming_by===\"Numbered\"",
"reqd": 1
},
{
"fieldname": "naming_section",
@ -69,7 +71,7 @@
"options": "Document Naming Rule Condition"
},
{
"description": "Rules with higher priority will be applied first.",
"description": "Rules with higher priority number will be applied first.",
"fieldname": "priority",
"fieldtype": "Int",
"label": "Priority"
@ -77,7 +79,7 @@
],
"index_web_pages_for_search": 1,
"links": [],
"modified": "2020-09-21 10:23:34.401539",
"modified": "2020-11-04 14:38:14.836056",
"modified_by": "Administrator",
"module": "Core",
"name": "Document Naming Rule",

View file

@ -13,7 +13,7 @@ class DocumentNamingRule(Document):
Apply naming rules for the given document. Will set `name` if the rule is matched.
'''
if self.conditions:
if not evaluate_filters(doc, [(d.field, d.condition, d.value) for d in self.conditions]):
if not evaluate_filters(doc, [(self.document_type, d.field, d.condition, d.value) for d in self.conditions]):
return
counter = frappe.db.get_value(self.doctype, self.name, 'counter', for_update=True) or 0