You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

50 line
2.0 KiB

  1. # Copyright (c) 2012 Web Notes Technologies Pvt Ltd (http://erpnext.com)
  2. #
  3. # MIT License (MIT)
  4. #
  5. # Permission is hereby granted, free of charge, to any person obtaining a
  6. # copy of this software and associated documentation files (the "Software"),
  7. # to deal in the Software without restriction, including without limitation
  8. # the rights to use, copy, modify, merge, publish, distribute, sublicense,
  9. # and/or sell copies of the Software, and to permit persons to whom the
  10. # Software is furnished to do so, subject to the following conditions:
  11. #
  12. # The above copyright notice and this permission notice shall be included in
  13. # all copies or substantial portions of the Software.
  14. #
  15. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
  16. # INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
  17. # PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
  18. # HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
  19. # CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
  20. # OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  21. #
  22. from __future__ import unicode_literals
  23. import webnotes
  24. workflow_names = {}
  25. def get_workflow_name(doctype):
  26. global workflow_names
  27. if not doctype in workflow_names:
  28. workflow_name = webnotes.conn.get_value("Workflow", {"document_type": doctype,
  29. "is_active": "1"}, "name")
  30. # no active? get default workflow
  31. if not workflow_name:
  32. workflow_name = webnotes.conn.get_value("Workflow", {"document_type": doctype,
  33. "is_custom": "No"}, "name")
  34. workflow_names[doctype] = workflow_name
  35. return workflow_names[doctype]
  36. def get_default_state(doctype):
  37. workflow_name = get_workflow_name(doctype)
  38. return webnotes.conn.get_value("Workflow Document State", {"parent":doctype,
  39. "idx":1}, "state")
  40. def get_state_fieldname(doctype):
  41. workflow_name = get_workflow_name(doctype)
  42. return webnotes.conn.get_value("Workflow", workflow_name, "workflow_state_field")