Browse Source

Renamed table fieldnames

version-14
Nabin Hait 10 years ago
parent
commit
a4d45cce6f
23 changed files with 513 additions and 493 deletions
  1. +1
    -1
      frappe/cli.py
  2. +91
    -91
      frappe/custom/doctype/customize_form/customize_form.json
  3. +6
    -6
      frappe/custom/doctype/customize_form/customize_form.py
  4. +21
    -21
      frappe/custom/doctype/customize_form/test_customize_form.py
  5. +222
    -222
      frappe/desk/doctype/event/event.json
  6. +2
    -2
      frappe/desk/doctype/event/event.py
  7. +1
    -1
      frappe/desk/doctype/event/test_records.json
  8. +1
    -1
      frappe/desk/form/meta.py
  9. +116
    -116
      frappe/email/doctype/email_alert/email_alert.json
  10. +1
    -1
      frappe/email/doctype/email_alert/email_alert.py
  11. +5
    -5
      frappe/email/doctype/email_alert/test_records.json
  12. +3
    -4
      frappe/model/__init__.py
  13. +2
    -2
      frappe/print/doctype/print_format/print_format.json
  14. +1
    -1
      frappe/public/js/frappe/form/grid.js
  15. +5
    -5
      frappe/public/js/frappe/model/workflow.js
  16. +1
    -1
      frappe/tests/test_client_login.py
  17. +1
    -1
      frappe/tests/test_data_import.py
  18. +2
    -2
      frappe/tests/test_document.py
  19. +1
    -0
      frappe/utils/pdf.py
  20. +6
    -0
      frappe/workflow/doctype/workflow/test_records.json
  21. +10
    -0
      frappe/workflow/doctype/workflow/test_workflow.py
  22. +11
    -7
      frappe/workflow/doctype/workflow/workflow.json
  23. +3
    -3
      frappe/workflow/doctype/workflow/workflow.py

+ 1
- 1
frappe/cli.py View File

@@ -937,7 +937,7 @@ def get_site_status(verbose=False):


# basic usage/progress analytics # basic usage/progress analytics
for doctype in ("Company", "Customer", "Item", "Quotation", "Sales Invoice", for doctype in ("Company", "Customer", "Item", "Quotation", "Sales Invoice",
"Journal Voucher", "Stock Ledger Entry"):
"Journal Entry", "Stock Ledger Entry"):
key = doctype.lower().replace(" ", "_") + "_exists" key = doctype.lower().replace(" ", "_") + "_exists"
ret[key] = 1 if frappe.db.count(doctype) else 0 ret[key] = 1 if frappe.db.count(doctype) else 0




+ 91
- 91
frappe/custom/doctype/customize_form/customize_form.json View File

@@ -1,123 +1,123 @@
{ {
"autoname": "DL.####",
"creation": "2013-01-29 17:55:08",
"docstatus": 0,
"doctype": "DocType",
"autoname": "DL.####",
"creation": "2013-01-29 17:55:08",
"docstatus": 0,
"doctype": "DocType",
"fields": [ "fields": [
{ {
"fieldname": "doc_type",
"fieldtype": "Link",
"hidden": 0,
"in_list_view": 1,
"label": "Enter Form Type",
"no_copy": 0,
"options": "DocType",
"permlevel": 0,
"fieldname": "doc_type",
"fieldtype": "Link",
"hidden": 0,
"in_list_view": 1,
"label": "Enter Form Type",
"no_copy": 0,
"options": "DocType",
"permlevel": 0,
"search_index": 0 "search_index": 0
},
},
{ {
"fieldname": "properties",
"fieldtype": "Section Break",
"label": "Properties",
"fieldname": "properties",
"fieldtype": "Section Break",
"label": "Properties",
"permlevel": 0 "permlevel": 0
},
},
{ {
"fieldname": "column_break0",
"fieldtype": "Column Break",
"fieldname": "column_break0",
"fieldtype": "Column Break",
"permlevel": 0 "permlevel": 0
},
},
{ {
"fieldname": "default_print_format",
"fieldtype": "Link",
"in_list_view": 1,
"label": "Default Print Format",
"no_copy": 0,
"options": "Print Format",
"permlevel": 0,
"fieldname": "default_print_format",
"fieldtype": "Link",
"in_list_view": 1,
"label": "Default Print Format",
"no_copy": 0,
"options": "Print Format",
"permlevel": 0,
"search_index": 0 "search_index": 0
},
},
{ {
"description": "Fields separated by comma (,) will be included in the<br /><b>Search By</b> list of Search dialog box",
"fieldname": "search_fields",
"fieldtype": "Data",
"in_list_view": 1,
"label": "Search Fields",
"no_copy": 0,
"permlevel": 0,
"description": "Fields separated by comma (,) will be included in the<br /><b>Search By</b> list of Search dialog box",
"fieldname": "search_fields",
"fieldtype": "Data",
"in_list_view": 1,
"label": "Search Fields",
"no_copy": 0,
"permlevel": 0,
"search_index": 0 "search_index": 0
},
},
{ {
"fieldname": "sort_field",
"fieldtype": "Data",
"label": "Sort Field",
"fieldname": "sort_field",
"fieldtype": "Data",
"label": "Sort Field",
"permlevel": 0 "permlevel": 0
},
},
{ {
"fieldname": "sort_order",
"fieldtype": "Data",
"label": "Sort Order",
"fieldname": "sort_order",
"fieldtype": "Data",
"label": "Sort Order",
"permlevel": 0 "permlevel": 0
},
},
{ {
"fieldname": "column_break1",
"fieldtype": "Column Break",
"fieldname": "column_break1",
"fieldtype": "Column Break",
"permlevel": 0 "permlevel": 0
},
},
{ {
"fieldname": "allow_copy",
"fieldtype": "Check",
"label": "Hide Copy",
"no_copy": 0,
"permlevel": 0,
"fieldname": "allow_copy",
"fieldtype": "Check",
"label": "Hide Copy",
"no_copy": 0,
"permlevel": 0,
"search_index": 0 "search_index": 0
},
},
{ {
"depends_on": "",
"fieldname": "max_attachments",
"fieldtype": "Int",
"label": "Max Attachments",
"no_copy": 0,
"permlevel": 0,
"depends_on": "",
"fieldname": "max_attachments",
"fieldtype": "Int",
"label": "Max Attachments",
"no_copy": 0,
"permlevel": 0,
"search_index": 0 "search_index": 0
},
},
{ {
"description": "Customize Label, Print Hide, Default etc.",
"fieldname": "fields_section_break",
"fieldtype": "Section Break",
"label": "Fields",
"description": "Customize Label, Print Hide, Default etc.",
"fieldname": "fields_section_break",
"fieldtype": "Section Break",
"label": "Fields",
"permlevel": 0 "permlevel": 0
},
},
{ {
"fieldname": "customize_form_fields",
"fieldtype": "Table",
"label": "Fields",
"no_copy": 0,
"options": "Customize Form Field",
"permlevel": 0,
"fieldname": "fields",
"fieldtype": "Table",
"label": "Fields",
"no_copy": 0,
"options": "Customize Form Field",
"permlevel": 0,
"search_index": 0 "search_index": 0
} }
],
"hide_toolbar": 1,
"icon": "icon-glass",
"idx": 1,
"issingle": 1,
"modified": "2014-08-22 05:42:45.083261",
"modified_by": "Administrator",
"module": "Custom",
"name": "Customize Form",
"owner": "Administrator",
],
"hide_toolbar": 1,
"icon": "icon-glass",
"idx": 1,
"issingle": 1,
"modified": "2014-12-24 15:22:06.314218",
"modified_by": "Administrator",
"module": "Custom",
"name": "Customize Form",
"owner": "Administrator",
"permissions": [ "permissions": [
{ {
"create": 1,
"email": 1,
"permlevel": 0,
"print": 1,
"read": 1,
"report": 0,
"role": "System Manager",
"submit": 0,
"create": 1,
"email": 1,
"permlevel": 0,
"print": 1,
"read": 1,
"report": 0,
"role": "System Manager",
"submit": 0,
"write": 1 "write": 1
} }
],
],
"search_fields": "doc_type" "search_fields": "doc_type"
}
}

+ 6
- 6
frappe/custom/doctype/customize_form/customize_form.py View File

@@ -68,7 +68,7 @@ class CustomizeForm(Document):
new_d = {"fieldname": d.fieldname, "is_custom_field": d.get("is_custom_field"), "name": d.name} new_d = {"fieldname": d.fieldname, "is_custom_field": d.get("is_custom_field"), "name": d.name}
for property in self.docfield_properties: for property in self.docfield_properties:
new_d[property] = d.get(property) new_d[property] = d.get(property)
self.append("customize_form_fields", new_d)
self.append("fields", new_d)


# NOTE doc is sent to clientside by run_method # NOTE doc is sent to clientside by run_method


@@ -106,7 +106,7 @@ class CustomizeForm(Document):
property_type=self.doctype_properties[property]) property_type=self.doctype_properties[property])


update_db = False update_db = False
for df in self.get("customize_form_fields"):
for df in self.get("fields"):
if df.get("__islocal"): if df.get("__islocal"):
continue continue


@@ -137,7 +137,7 @@ class CustomizeForm(Document):
updatedb(self.doc_type) updatedb(self.doc_type)


def update_custom_fields(self): def update_custom_fields(self):
for df in self.get("customize_form_fields"):
for df in self.get("fields"):
if df.get("__islocal"): if df.get("__islocal"):
self.add_custom_field(df) self.add_custom_field(df)
else: else:
@@ -176,7 +176,7 @@ class CustomizeForm(Document):
def delete_custom_fields(self): def delete_custom_fields(self):
meta = frappe.get_meta(self.doc_type) meta = frappe.get_meta(self.doc_type)
fields_to_remove = (set([df.fieldname for df in meta.get("fields")]) fields_to_remove = (set([df.fieldname for df in meta.get("fields")])
- set(df.fieldname for df in self.get("customize_form_fields")))
- set(df.fieldname for df in self.get("fields")))


for fieldname in fields_to_remove: for fieldname in fields_to_remove:
df = meta.get("fields", {"fieldname": fieldname})[0] df = meta.get("fields", {"fieldname": fieldname})[0]
@@ -186,11 +186,11 @@ class CustomizeForm(Document):
def set_idx_property_setter(self): def set_idx_property_setter(self):
meta = frappe.get_meta(self.doc_type) meta = frappe.get_meta(self.doc_type)
field_order_has_changed = [df.fieldname for df in meta.get("fields")] != \ field_order_has_changed = [df.fieldname for df in meta.get("fields")] != \
[d.fieldname for d in self.get("customize_form_fields")]
[d.fieldname for d in self.get("fields")]


if field_order_has_changed: if field_order_has_changed:
_idx = [] _idx = []
for df in sorted(self.get("customize_form_fields"), key=lambda x: x.idx):
for df in sorted(self.get("fields"), key=lambda x: x.idx):
_idx.append(df.fieldname) _idx.append(df.fieldname)


self.make_property_setter(property="_idx", value=json.dumps(_idx), property_type="Text") self.make_property_setter(property="_idx", value=json.dumps(_idx), property_type="Text")


+ 21
- 21
frappe/custom/doctype/customize_form/test_customize_form.py View File

@@ -39,28 +39,28 @@ class TestCustomizeForm(unittest.TestCase):
def test_fetch_to_customize(self): def test_fetch_to_customize(self):
d = self.get_customize_form() d = self.get_customize_form()
self.assertEquals(d.doc_type, None) self.assertEquals(d.doc_type, None)
self.assertEquals(len(d.get("customize_form_fields")), 0)
self.assertEquals(len(d.get("fields")), 0)


d = self.get_customize_form("Event") d = self.get_customize_form("Event")
self.assertEquals(d.doc_type, "Event") self.assertEquals(d.doc_type, "Event")
self.assertEquals(len(d.get("customize_form_fields")), 30)
self.assertEquals(len(d.get("fields")), 30)


d = self.get_customize_form("User") d = self.get_customize_form("User")
self.assertEquals(d.doc_type, "User") self.assertEquals(d.doc_type, "User")
self.assertEquals(len(d.get("customize_form_fields")), 55)
self.assertEquals(d.get("customize_form_fields")[-1].fieldname, "test_custom_field")
self.assertEquals(d.get("customize_form_fields", {"fieldname": "location"})[0].in_list_view, 1)
self.assertEquals(len(d.get("fields")), 55)
self.assertEquals(d.get("fields")[-1].fieldname, "test_custom_field")
self.assertEquals(d.get("fields", {"fieldname": "location"})[0].in_list_view, 1)


return d return d


def test_save_customization_idx(self): def test_save_customization_idx(self):
d = self.get_customize_form("User") d = self.get_customize_form("User")
original_sequence = [df.fieldname for df in d.get("customize_form_fields")]
original_sequence = [df.fieldname for df in d.get("fields")]


# move field to last # move field to last
location_field = d.get("customize_form_fields", {"fieldname": "location"})[0]
d.get("customize_form_fields").remove(location_field)
d.append("customize_form_fields", location_field)
location_field = d.get("fields", {"fieldname": "location"})[0]
d.get("fields").remove(location_field)
d.append("fields", location_field)
d.run_method("save_customization") d.run_method("save_customization")
frappe.clear_cache(doctype=d.doc_type) frappe.clear_cache(doctype=d.doc_type)


@@ -98,13 +98,13 @@ class TestCustomizeForm(unittest.TestCase):
self.assertEquals(frappe.db.get_value("Property Setter", self.assertEquals(frappe.db.get_value("Property Setter",
{"doc_type": "User", "property": "reqd", "field_name": "location"}, "value"), None) {"doc_type": "User", "property": "reqd", "field_name": "location"}, "value"), None)


location_field = d.get("customize_form_fields", {"fieldname": "location"})[0]
location_field = d.get("fields", {"fieldname": "location"})[0]
location_field.reqd = 1 location_field.reqd = 1
d.run_method("save_customization") d.run_method("save_customization")
self.assertEquals(frappe.db.get_value("Property Setter", self.assertEquals(frappe.db.get_value("Property Setter",
{"doc_type": "User", "property": "reqd", "field_name": "location"}, "value"), '1') {"doc_type": "User", "property": "reqd", "field_name": "location"}, "value"), '1')


location_field = d.get("customize_form_fields", {"fieldname": "location"})[0]
location_field = d.get("fields", {"fieldname": "location"})[0]
location_field.reqd = 0 location_field.reqd = 0
d.run_method("save_customization") d.run_method("save_customization")
self.assertEquals(frappe.db.get_value("Property Setter", self.assertEquals(frappe.db.get_value("Property Setter",
@@ -114,19 +114,19 @@ class TestCustomizeForm(unittest.TestCase):
d = self.get_customize_form("User") d = self.get_customize_form("User")
self.assertEquals(frappe.db.get_value("Custom Field", "User-test_custom_field", "reqd"), 0) self.assertEquals(frappe.db.get_value("Custom Field", "User-test_custom_field", "reqd"), 0)


custom_field = d.get("customize_form_fields", {"fieldname": "test_custom_field"})[0]
custom_field = d.get("fields", {"fieldname": "test_custom_field"})[0]
custom_field.reqd = 1 custom_field.reqd = 1
d.run_method("save_customization") d.run_method("save_customization")
self.assertEquals(frappe.db.get_value("Custom Field", "User-test_custom_field", "reqd"), 1) self.assertEquals(frappe.db.get_value("Custom Field", "User-test_custom_field", "reqd"), 1)


custom_field = d.get("customize_form_fields", {"is_custom_field": True})[0]
custom_field = d.get("fields", {"is_custom_field": True})[0]
custom_field.reqd = 0 custom_field.reqd = 0
d.run_method("save_customization") d.run_method("save_customization")
self.assertEquals(frappe.db.get_value("Custom Field", "User-test_custom_field", "reqd"), 0) self.assertEquals(frappe.db.get_value("Custom Field", "User-test_custom_field", "reqd"), 0)


def test_save_customization_new_field(self): def test_save_customization_new_field(self):
d = self.get_customize_form("User") d = self.get_customize_form("User")
d.append("customize_form_fields", {
d.append("fields", {
"label": "Test Add Custom Field Via Customize Form", "label": "Test Add Custom Field Via Customize Form",
"fieldtype": "Data", "fieldtype": "Data",
"__islocal": 1 "__islocal": 1
@@ -141,8 +141,8 @@ class TestCustomizeForm(unittest.TestCase):


def test_save_customization_remove_field(self): def test_save_customization_remove_field(self):
d = self.get_customize_form("User") d = self.get_customize_form("User")
custom_field = d.get("customize_form_fields", {"fieldname": "test_custom_field"})[0]
d.get("customize_form_fields").remove(custom_field)
custom_field = d.get("fields", {"fieldname": "test_custom_field"})[0]
d.get("fields").remove(custom_field)
d.run_method("save_customization") d.run_method("save_customization")


self.assertEquals(frappe.db.get_value("Custom Field", custom_field.name), None) self.assertEquals(frappe.db.get_value("Custom Field", custom_field.name), None)
@@ -155,21 +155,21 @@ class TestCustomizeForm(unittest.TestCase):
d.doc_type = "User" d.doc_type = "User"
d.run_method('reset_to_defaults') d.run_method('reset_to_defaults')


self.assertEquals(d.get("customize_form_fields", {"fieldname": "location"})[0].in_list_view, None)
self.assertEquals(d.get("fields", {"fieldname": "location"})[0].in_list_view, None)


frappe.local.test_objects["Property Setter"] = [] frappe.local.test_objects["Property Setter"] = []
make_test_records_for_doctype("Property Setter") make_test_records_for_doctype("Property Setter")


def test_set_allow_on_submit(self): def test_set_allow_on_submit(self):
d = self.get_customize_form("User") d = self.get_customize_form("User")
d.get("customize_form_fields", {"fieldname": "first_name"})[0].allow_on_submit = 1
d.get("customize_form_fields", {"fieldname": "test_custom_field"})[0].allow_on_submit = 1
d.get("fields", {"fieldname": "first_name"})[0].allow_on_submit = 1
d.get("fields", {"fieldname": "test_custom_field"})[0].allow_on_submit = 1
d.run_method("save_customization") d.run_method("save_customization")


d = self.get_customize_form("User") d = self.get_customize_form("User")


# don't allow for standard fields # don't allow for standard fields
self.assertEquals(d.get("customize_form_fields", {"fieldname": "first_name"})[0].allow_on_submit or 0, 0)
self.assertEquals(d.get("fields", {"fieldname": "first_name"})[0].allow_on_submit or 0, 0)


# allow for custom field # allow for custom field
self.assertEquals(d.get("customize_form_fields", {"fieldname": "test_custom_field"})[0].allow_on_submit, 1)
self.assertEquals(d.get("fields", {"fieldname": "test_custom_field"})[0].allow_on_submit, 1)

+ 222
- 222
frappe/desk/doctype/event/event.json View File

@@ -1,283 +1,283 @@
{ {
"autoname": "EV.#####",
"creation": "2013-06-10 13:17:47",
"docstatus": 0,
"doctype": "DocType",
"autoname": "EV.#####",
"creation": "2013-06-10 13:17:47",
"docstatus": 0,
"doctype": "DocType",
"fields": [ "fields": [
{ {
"fieldname": "details",
"fieldtype": "Section Break",
"label": "Details",
"oldfieldtype": "Section Break",
"fieldname": "details",
"fieldtype": "Section Break",
"label": "Details",
"oldfieldtype": "Section Break",
"permlevel": 0 "permlevel": 0
},
},
{ {
"fieldname": "subject",
"fieldtype": "Data",
"in_list_view": 1,
"label": "Subject",
"permlevel": 0,
"fieldname": "subject",
"fieldtype": "Data",
"in_list_view": 1,
"label": "Subject",
"permlevel": 0,
"reqd": 1 "reqd": 1
},
{
"fieldname": "event_type",
"fieldtype": "Select",
"in_list_view": 1,
"label": "Event Type",
"no_copy": 0,
"oldfieldname": "event_type",
"oldfieldtype": "Select",
"options": "Private\nPublic\nCancel",
"permlevel": 0,
"reqd": 1,
},
{
"fieldname": "event_type",
"fieldtype": "Select",
"in_list_view": 1,
"label": "Event Type",
"no_copy": 0,
"oldfieldname": "event_type",
"oldfieldtype": "Select",
"options": "Private\nPublic\nCancel",
"permlevel": 0,
"reqd": 1,
"search_index": 1 "search_index": 1
},
},
{ {
"default": "1",
"fieldname": "send_reminder",
"fieldtype": "Check",
"label": "Send an email reminder in the morning",
"default": "1",
"fieldname": "send_reminder",
"fieldtype": "Check",
"label": "Send an email reminder in the morning",
"permlevel": 0 "permlevel": 0
},
},
{ {
"fieldname": "column_break_4",
"fieldtype": "Column Break",
"fieldname": "column_break_4",
"fieldtype": "Column Break",
"permlevel": 0 "permlevel": 0
},
},
{ {
"fieldname": "all_day",
"fieldtype": "Check",
"label": "All Day",
"fieldname": "all_day",
"fieldtype": "Check",
"label": "All Day",
"permlevel": 0 "permlevel": 0
},
},
{ {
"fieldname": "starts_on",
"fieldtype": "Datetime",
"label": "Starts on",
"permlevel": 0,
"fieldname": "starts_on",
"fieldtype": "Datetime",
"label": "Starts on",
"permlevel": 0,
"reqd": 1 "reqd": 1
},
},
{ {
"fieldname": "ends_on",
"fieldtype": "Datetime",
"label": "Ends on",
"permlevel": 0,
"fieldname": "ends_on",
"fieldtype": "Datetime",
"label": "Ends on",
"permlevel": 0,
"reqd": 0 "reqd": 0
},
},
{ {
"fieldname": "section_break_8",
"fieldtype": "Section Break",
"fieldname": "section_break_8",
"fieldtype": "Section Break",
"permlevel": 0 "permlevel": 0
},
},
{ {
"fieldname": "repeat_this_event",
"fieldtype": "Check",
"label": "Repeat this Event",
"fieldname": "repeat_this_event",
"fieldtype": "Check",
"label": "Repeat this Event",
"permlevel": 0 "permlevel": 0
},
},
{ {
"depends_on": "repeat_this_event",
"fieldname": "section_break_11",
"fieldtype": "Section Break",
"depends_on": "repeat_this_event",
"fieldname": "section_break_11",
"fieldtype": "Section Break",
"permlevel": 0 "permlevel": 0
},
},
{ {
"depends_on": "repeat_this_event",
"fieldname": "repeat_on",
"fieldtype": "Select",
"label": "Repeat On",
"options": "\nEvery Day\nEvery Week\nEvery Month\nEvery Year",
"depends_on": "repeat_this_event",
"fieldname": "repeat_on",
"fieldtype": "Select",
"label": "Repeat On",
"options": "\nEvery Day\nEvery Week\nEvery Month\nEvery Year",
"permlevel": 0 "permlevel": 0
},
},
{ {
"depends_on": "repeat_this_event",
"description": "Leave blank to repeat always",
"fieldname": "repeat_till",
"fieldtype": "Date",
"label": "Repeat Till",
"depends_on": "repeat_this_event",
"description": "Leave blank to repeat always",
"fieldname": "repeat_till",
"fieldtype": "Date",
"label": "Repeat Till",
"permlevel": 0 "permlevel": 0
},
},
{ {
"fieldname": "column_break_11",
"fieldtype": "Column Break",
"fieldname": "column_break_11",
"fieldtype": "Column Break",
"permlevel": 0 "permlevel": 0
},
},
{ {
"depends_on": "eval:doc.repeat_this_event && doc.repeat_on===\"Every Day\"",
"fieldname": "monday",
"fieldtype": "Check",
"label": "Monday",
"depends_on": "eval:doc.repeat_this_event && doc.repeat_on===\"Every Day\"",
"fieldname": "monday",
"fieldtype": "Check",
"label": "Monday",
"permlevel": 0 "permlevel": 0
},
},
{ {
"depends_on": "eval:doc.repeat_this_event && doc.repeat_on===\"Every Day\"",
"fieldname": "tuesday",
"fieldtype": "Check",
"label": "Tuesday",
"depends_on": "eval:doc.repeat_this_event && doc.repeat_on===\"Every Day\"",
"fieldname": "tuesday",
"fieldtype": "Check",
"label": "Tuesday",
"permlevel": 0 "permlevel": 0
},
},
{ {
"depends_on": "eval:doc.repeat_this_event && doc.repeat_on===\"Every Day\"",
"fieldname": "wednesday",
"fieldtype": "Check",
"label": "Wednesday",
"depends_on": "eval:doc.repeat_this_event && doc.repeat_on===\"Every Day\"",
"fieldname": "wednesday",
"fieldtype": "Check",
"label": "Wednesday",
"permlevel": 0 "permlevel": 0
},
},
{ {
"depends_on": "eval:doc.repeat_this_event && doc.repeat_on===\"Every Day\"",
"fieldname": "thursday",
"fieldtype": "Check",
"label": "Thursday",
"depends_on": "eval:doc.repeat_this_event && doc.repeat_on===\"Every Day\"",
"fieldname": "thursday",
"fieldtype": "Check",
"label": "Thursday",
"permlevel": 0 "permlevel": 0
},
},
{ {
"depends_on": "eval:doc.repeat_this_event && doc.repeat_on===\"Every Day\"",
"fieldname": "friday",
"fieldtype": "Check",
"label": "Friday",
"depends_on": "eval:doc.repeat_this_event && doc.repeat_on===\"Every Day\"",
"fieldname": "friday",
"fieldtype": "Check",
"label": "Friday",
"permlevel": 0 "permlevel": 0
},
},
{ {
"depends_on": "eval:doc.repeat_this_event && doc.repeat_on===\"Every Day\"",
"fieldname": "saturday",
"fieldtype": "Check",
"label": "Saturday",
"depends_on": "eval:doc.repeat_this_event && doc.repeat_on===\"Every Day\"",
"fieldname": "saturday",
"fieldtype": "Check",
"label": "Saturday",
"permlevel": 0 "permlevel": 0
},
},
{ {
"depends_on": "eval:doc.repeat_this_event && doc.repeat_on===\"Every Day\"",
"fieldname": "sunday",
"fieldtype": "Check",
"label": "Sunday",
"depends_on": "eval:doc.repeat_this_event && doc.repeat_on===\"Every Day\"",
"fieldname": "sunday",
"fieldtype": "Check",
"label": "Sunday",
"permlevel": 0 "permlevel": 0
},
},
{ {
"fieldname": "section_break_6",
"fieldtype": "Section Break",
"fieldname": "section_break_6",
"fieldtype": "Section Break",
"permlevel": 0 "permlevel": 0
},
{
"fieldname": "description",
"fieldtype": "Text Editor",
"in_list_view": 0,
"label": "Description",
"no_copy": 0,
"oldfieldname": "description",
"oldfieldtype": "Text",
"permlevel": 0,
"print_width": "300px",
"search_index": 0,
},
{
"fieldname": "description",
"fieldtype": "Text Editor",
"in_list_view": 0,
"label": "Description",
"no_copy": 0,
"oldfieldname": "description",
"oldfieldtype": "Text",
"permlevel": 0,
"print_width": "300px",
"search_index": 0,
"width": "300px" "width": "300px"
},
},
{ {
"fieldname": "participants",
"fieldtype": "Section Break",
"label": "Participants",
"oldfieldtype": "Section Break",
"fieldname": "participants",
"fieldtype": "Section Break",
"label": "Participants",
"oldfieldtype": "Section Break",
"permlevel": 0 "permlevel": 0
},
{
"fieldname": "individuals",
"fieldtype": "Column Break",
"label": "Individuals",
"oldfieldtype": "Column Break",
"permlevel": 0,
"print_width": "50%",
},
{
"fieldname": "individuals",
"fieldtype": "Column Break",
"label": "Individuals",
"oldfieldtype": "Column Break",
"permlevel": 0,
"print_width": "50%",
"width": "50%" "width": "50%"
},
{
"fieldname": "event_individuals",
"fieldtype": "Table",
"label": "Event Individuals",
"no_copy": 0,
"oldfieldname": "event_individuals",
"oldfieldtype": "Table",
"options": "Event User",
"permlevel": 0,
},
{
"fieldname": "users",
"fieldtype": "Table",
"label": "Users",
"no_copy": 0,
"oldfieldname": "event_individuals",
"oldfieldtype": "Table",
"options": "Event User",
"permlevel": 0,
"search_index": 0 "search_index": 0
},
{
"fieldname": "groups",
"fieldtype": "Column Break",
"label": "Groups",
"oldfieldtype": "Column Break",
"permlevel": 0,
"print_width": "50%",
},
{
"fieldname": "groups",
"fieldtype": "Column Break",
"label": "Groups",
"oldfieldtype": "Column Break",
"permlevel": 0,
"print_width": "50%",
"width": "50%" "width": "50%"
},
{
"fieldname": "event_roles",
"fieldtype": "Table",
"label": "Event Roles",
"no_copy": 0,
"oldfieldname": "event_roles",
"oldfieldtype": "Table",
"options": "Event Role",
"permlevel": 0,
},
{
"fieldname": "roles",
"fieldtype": "Table",
"label": "Roles",
"no_copy": 0,
"oldfieldname": "event_roles",
"oldfieldtype": "Table",
"options": "Event Role",
"permlevel": 0,
"search_index": 0 "search_index": 0
},
{
"fieldname": "ref_type",
"fieldtype": "Link",
"hidden": 0,
"label": "Ref Type",
"no_copy": 0,
"oldfieldname": "ref_type",
"oldfieldtype": "Data",
"options": "DocType",
"permlevel": 0,
"read_only": 0,
},
{
"fieldname": "ref_type",
"fieldtype": "Link",
"hidden": 0,
"label": "Ref Type",
"no_copy": 0,
"oldfieldname": "ref_type",
"oldfieldtype": "Data",
"options": "DocType",
"permlevel": 0,
"read_only": 0,
"search_index": 0 "search_index": 0
},
{
"fieldname": "ref_name",
"fieldtype": "Dynamic Link",
"hidden": 0,
"label": "Ref Name",
"no_copy": 0,
"oldfieldname": "ref_name",
"oldfieldtype": "Data",
"options": "ref_type",
"permlevel": 0,
"read_only": 1,
},
{
"fieldname": "ref_name",
"fieldtype": "Dynamic Link",
"hidden": 0,
"label": "Ref Name",
"no_copy": 0,
"oldfieldname": "ref_name",
"oldfieldtype": "Data",
"options": "ref_type",
"permlevel": 0,
"read_only": 1,
"search_index": 0 "search_index": 0
} }
],
"icon": "icon-calendar",
"idx": 1,
"in_create": 1,
"modified": "2014-06-20 06:40:05.415415",
"modified_by": "Administrator",
"module": "Desk",
"name": "Event",
"owner": "Administrator",
],
"icon": "icon-calendar",
"idx": 1,
"in_create": 1,
"modified": "2014-12-24 15:30:22.606715",
"modified_by": "Administrator",
"module": "Desk",
"name": "Event",
"owner": "Administrator",
"permissions": [ "permissions": [
{ {
"apply_user_permissions": 1,
"create": 1,
"delete": 0,
"email": 1,
"permlevel": 0,
"print": 1,
"read": 1,
"report": 1,
"role": "All",
"submit": 0,
"apply_user_permissions": 1,
"create": 1,
"delete": 0,
"email": 1,
"permlevel": 0,
"print": 1,
"read": 1,
"report": 1,
"role": "All",
"submit": 0,
"write": 1 "write": 1
},
{
"create": 1,
"delete": 1,
"email": 1,
"permlevel": 0,
"print": 1,
"read": 1,
"report": 1,
"role": "System Manager",
"submit": 0,
},
{
"create": 1,
"delete": 1,
"email": 1,
"permlevel": 0,
"print": 1,
"read": 1,
"report": 1,
"role": "System Manager",
"submit": 0,
"write": 1 "write": 1
} }
],
"read_only": 1,
],
"read_only": 1,
"title_field": "subject" "title_field": "subject"
}
}

+ 2
- 2
frappe/desk/doctype/event/event.py View File

@@ -35,10 +35,10 @@ def has_permission(doc, user):
if doc.event_type=="Public" or doc.owner==user: if doc.event_type=="Public" or doc.owner==user:
return True return True


if doc.get("event_individuals", {"person": user}):
if doc.get("users", {"person": user}):
return True return True


if doc.get("event_roles", {"role":("in", frappe.get_roles(user))}):
if doc.get("roles", {"role":("in", frappe.get_roles(user))}):
return True return True


return False return False


+ 1
- 1
frappe/desk/doctype/event/test_records.json View File

@@ -16,7 +16,7 @@
"starts_on": "2014-01-01", "starts_on": "2014-01-01",
"subject":"_Test Event 3", "subject":"_Test Event 3",
"event_type": "Private", "event_type": "Private",
"event_individuals": [{
"users": [{
"person": "test1@example.com" "person": "test1@example.com"
}] }]
} }


+ 1
- 1
frappe/desk/form/meta.py View File

@@ -157,7 +157,7 @@ class FormMeta(Meta):
workflow = frappe.get_doc("Workflow", workflow_name) workflow = frappe.get_doc("Workflow", workflow_name)
workflow_docs.append(workflow) workflow_docs.append(workflow)


for d in workflow.get("workflow_document_states"):
for d in workflow.get("states"):
workflow_docs.append(frappe.get_doc("Workflow State", d.state)) workflow_docs.append(frappe.get_doc("Workflow State", d.state))


self.set("__workflow_docs", workflow_docs) self.set("__workflow_docs", workflow_docs)


+ 116
- 116
frappe/email/doctype/email_alert/email_alert.json View File

@@ -1,152 +1,152 @@
{ {
"autoname": "hash",
"creation": "2014-07-11 17:18:09.923399",
"docstatus": 0,
"doctype": "DocType",
"document_type": "System",
"autoname": "hash",
"creation": "2014-07-11 17:18:09.923399",
"docstatus": 0,
"doctype": "DocType",
"document_type": "System",
"fields": [ "fields": [
{ {
"default": "1",
"fieldname": "enabled",
"fieldtype": "Check",
"label": "Enabled",
"default": "1",
"fieldname": "enabled",
"fieldtype": "Check",
"label": "Enabled",
"permlevel": 0 "permlevel": 0
},
},
{ {
"fieldname": "filters",
"fieldtype": "Section Break",
"label": "Filters",
"fieldname": "filters",
"fieldtype": "Section Break",
"label": "Filters",
"permlevel": 0 "permlevel": 0
},
},
{ {
"fieldname": "subject",
"fieldtype": "Data",
"in_list_view": 1,
"label": "Subject",
"permlevel": 0,
"fieldname": "subject",
"fieldtype": "Data",
"in_list_view": 1,
"label": "Subject",
"permlevel": 0,
"reqd": 1 "reqd": 1
},
{
"fieldname": "document_type",
"fieldtype": "Link",
"in_list_view": 1,
"label": "Document Type",
"options": "DocType",
"permlevel": 0,
"reqd": 1,
},
{
"fieldname": "document_type",
"fieldtype": "Link",
"in_list_view": 1,
"label": "Document Type",
"options": "DocType",
"permlevel": 0,
"reqd": 1,
"search_index": 1 "search_index": 1
},
{
"fieldname": "event",
"fieldtype": "Select",
"in_list_view": 1,
"label": "Send Alert On",
"options": "\nNew\nSave\nSubmit\nCancel\nDate Change\nValue Change",
"permlevel": 0,
"reqd": 1,
},
{
"fieldname": "event",
"fieldtype": "Select",
"in_list_view": 1,
"label": "Send Alert On",
"options": "\nNew\nSave\nSubmit\nCancel\nDate Change\nValue Change",
"permlevel": 0,
"reqd": 1,
"search_index": 1 "search_index": 1
},
},
{ {
"depends_on": "eval:doc.event==\"Date Change\"",
"description": "Send alert if date matches this field's value",
"fieldname": "date_changed",
"fieldtype": "Select",
"label": "Date Changed",
"depends_on": "eval:doc.event==\"Date Change\"",
"description": "Send alert if date matches this field's value",
"fieldname": "date_changed",
"fieldtype": "Select",
"label": "Date Changed",
"permlevel": 0 "permlevel": 0
},
{
"default": "0",
"depends_on": "eval:doc.event==\"Date Change\"",
"description": "[Optional] Send the email X days in advance of the specified date. 0 equals same day.",
"fieldname": "days_in_advance",
"fieldtype": "Int",
"label": "Days in Advance",
},
{
"default": "0",
"depends_on": "eval:doc.event==\"Date Change\"",
"description": "[Optional] Send the email X days in advance of the specified date. 0 equals same day.",
"fieldname": "days_in_advance",
"fieldtype": "Int",
"label": "Days in Advance",
"permlevel": 0 "permlevel": 0
},
},
{ {
"depends_on": "eval:doc.event==\"Value Change\"",
"description": "Send alert if this field's value changes",
"fieldname": "value_changed",
"fieldtype": "Select",
"label": "Value Changed",
"depends_on": "eval:doc.event==\"Value Change\"",
"description": "Send alert if this field's value changes",
"fieldname": "value_changed",
"fieldtype": "Select",
"label": "Value Changed",
"permlevel": 0 "permlevel": 0
},
{
"depends_on": "",
"description": "Optional: The alert will be sent if this expression is true",
"fieldname": "condition",
"fieldtype": "Data",
"in_list_view": 1,
"label": "Condition",
},
{
"depends_on": "",
"description": "Optional: The alert will be sent if this expression is true",
"fieldname": "condition",
"fieldtype": "Data",
"in_list_view": 1,
"label": "Condition",
"permlevel": 0 "permlevel": 0
},
},
{ {
"fieldname": "column_break_6",
"fieldtype": "Column Break",
"fieldname": "column_break_6",
"fieldtype": "Column Break",
"permlevel": 0 "permlevel": 0
},
},
{ {
"fieldname": "html_7",
"fieldtype": "HTML",
"options": "<p><strong>Condition Examples:</strong></p>\n<pre>doc.status==\"Open\"\ndoc.due_date==nowdate()\ndoc.total > 40000\n</pre>\n<p><strong>Hints:</strong></p>\n<ol>\n<li>To check for an event every day, select \"Date Change\" in Event</li>\n<li>To send an alert if a particular value changes, select \"Value Change\"</li>\n</ol>",
"fieldname": "html_7",
"fieldtype": "HTML",
"options": "<p><strong>Condition Examples:</strong></p>\n<pre>doc.status==\"Open\"\ndoc.due_date==nowdate()\ndoc.total > 40000\n</pre>\n<p><strong>Hints:</strong></p>\n<ol>\n<li>To check for an event every day, select \"Date Change\" in Event</li>\n<li>To send an alert if a particular value changes, select \"Value Change\"</li>\n</ol>",
"permlevel": 0 "permlevel": 0
},
},
{ {
"fieldname": "column_break_5",
"fieldtype": "Section Break",
"label": "Recipients",
"fieldname": "column_break_5",
"fieldtype": "Section Break",
"label": "Recipients",
"permlevel": 0 "permlevel": 0
},
},
{ {
"fieldname": "email_alert_recipients",
"fieldtype": "Table",
"label": "Email Alert Recipients",
"options": "Email Alert Recipient",
"permlevel": 0,
"fieldname": "recipients",
"fieldtype": "Table",
"label": "Recipients",
"options": "Email Alert Recipient",
"permlevel": 0,
"reqd": 1 "reqd": 1
},
},
{ {
"fieldname": "message_sb",
"fieldtype": "Section Break",
"label": "Message",
"fieldname": "message_sb",
"fieldtype": "Section Break",
"label": "Message",
"permlevel": 0 "permlevel": 0
},
},
{ {
"fieldname": "message",
"fieldtype": "Text",
"label": "Message",
"permlevel": 0,
"fieldname": "message",
"fieldtype": "Text",
"label": "Message",
"permlevel": 0,
"reqd": 1 "reqd": 1
},
},
{ {
"fieldname": "message_examples",
"fieldtype": "HTML",
"label": "Message Examples",
"options": "<h5>Message Example (Markdown)</h5>\n<pre>Transaction {{ doc.name }} has exceeded Due Date. Please take relevant action\n\n#### Details\n\nCustomer: {{ doc.customer }}\nAmount: {{ doc.total_amount }}</pre>",
"fieldname": "message_examples",
"fieldtype": "HTML",
"label": "Message Examples",
"options": "<h5>Message Example (Markdown)</h5>\n<pre>Transaction {{ doc.name }} has exceeded Due Date. Please take relevant action\n\n#### Details\n\nCustomer: {{ doc.customer }}\nAmount: {{ doc.total_amount }}</pre>",
"permlevel": 0 "permlevel": 0
} }
],
"icon": "icon-envelope",
"modified": "2014-07-15 05:07:14.002361",
"modified_by": "Administrator",
"module": "Email",
"name": "Email Alert",
"name_case": "",
"owner": "Administrator",
],
"icon": "icon-envelope",
"modified": "2014-12-24 15:23:38.989963",
"modified_by": "Administrator",
"module": "Email",
"name": "Email Alert",
"name_case": "",
"owner": "Administrator",
"permissions": [ "permissions": [
{ {
"create": 1,
"delete": 1,
"export": 1,
"import": 0,
"permlevel": 0,
"read": 1,
"report": 1,
"role": "System Manager",
"create": 1,
"delete": 1,
"export": 1,
"import": 0,
"permlevel": 0,
"read": 1,
"report": 1,
"role": "System Manager",
"write": 1 "write": 1
} }
],
"sort_field": "modified",
"sort_order": "DESC",
],
"sort_field": "modified",
"sort_order": "DESC",
"title_field": "subject" "title_field": "subject"
}
}

+ 1
- 1
frappe/email/doctype/email_alert/email_alert.py View File

@@ -72,7 +72,7 @@ def evaluate_alert(doc, alert, event):
doc.name, alert.value_changed): doc.name, alert.value_changed):
return # value not changed return # value not changed


for recipient in alert.email_alert_recipients:
for recipient in alert.recipients:
recipients = [] recipients = []
if recipient.condition: if recipient.condition:
if not eval(recipient.condition, context): if not eval(recipient.condition, context):


+ 5
- 5
frappe/email/doctype/email_alert/test_records.json View File

@@ -5,7 +5,7 @@
"document_type": "Comment", "document_type": "Comment",
"event": "New", "event": "New",
"message": "New comment {{ doc.comment }} created", "message": "New comment {{ doc.comment }} created",
"email_alert_recipients": [
"recipients": [
{ "email_by_document_field": "owner" } { "email_by_document_field": "owner" }
] ]
}, },
@@ -15,7 +15,7 @@
"document_type": "Comment", "document_type": "Comment",
"event": "Save", "event": "Save",
"message": "New comment {{ doc.comment }} saved", "message": "New comment {{ doc.comment }} saved",
"email_alert_recipients": [
"recipients": [
{ "email_by_document_field": "owner" } { "email_by_document_field": "owner" }
] ]
}, },
@@ -26,7 +26,7 @@
"event": "Save", "event": "Save",
"condition": "doc.event_type=='Public'", "condition": "doc.event_type=='Public'",
"message": "A new public event {{ doc.subject }} on {{ doc.starts_on }} is created", "message": "A new public event {{ doc.subject }} on {{ doc.starts_on }} is created",
"email_alert_recipients": [
"recipients": [
{ "email_by_document_field": "owner" } { "email_by_document_field": "owner" }
] ]
}, },
@@ -37,7 +37,7 @@
"event": "Value Change", "event": "Value Change",
"value_changed": "description", "value_changed": "description",
"message": "Description changed", "message": "Description changed",
"email_alert_recipients": [
"recipients": [
{ "email_by_document_field": "owner" } { "email_by_document_field": "owner" }
] ]
}, },
@@ -49,7 +49,7 @@
"date_changed": "starts_on", "date_changed": "starts_on",
"days_in_advance": 2, "days_in_advance": 2,
"message": "Description changed", "message": "Description changed",
"email_alert_recipients": [
"recipients": [
{ "email_by_document_field": "owner" } { "email_by_document_field": "owner" }
] ]
} }


+ 3
- 4
frappe/model/__init__.py View File

@@ -35,7 +35,6 @@ def copytables(srctype, src, srcfield, tartype, tar, tarfield, srcfields, tarfie
return l return l


def db_exists(dt, dn): def db_exists(dt, dn):
import frappe
return frappe.db.exists(dt, dn) return frappe.db.exists(dt, dn)


def delete_fields(args_dict, delete=0): def delete_fields(args_dict, delete=0):
@@ -97,13 +96,13 @@ def rename_field(doctype, old_fieldname, new_fieldname):
frappe.db.sql("""update `tab%s` set `%s`=`%s`""" % \ frappe.db.sql("""update `tab%s` set `%s`=`%s`""" % \
(doctype, new_fieldname, old_fieldname)) (doctype, new_fieldname, old_fieldname))


update_reports(doctype, old_fieldname, new_fieldname)
update_users_report_view_settings(doctype, old_fieldname, new_fieldname)

# update in property setter # update in property setter
frappe.db.sql("""update `tabProperty Setter` set field_name = %s frappe.db.sql("""update `tabProperty Setter` set field_name = %s
where doc_type=%s and field_name=%s""", (new_fieldname, doctype, old_fieldname)) where doc_type=%s and field_name=%s""", (new_fieldname, doctype, old_fieldname))


update_reports(doctype, old_fieldname, new_fieldname)
update_users_report_view_settings(doctype, old_fieldname, new_fieldname)

def update_reports(doctype, old_fieldname, new_fieldname): def update_reports(doctype, old_fieldname, new_fieldname):
def _get_new_sort_by(report_dict, report, key): def _get_new_sort_by(report_dict, report, key):
sort_by = report_dict.get(key) or "" sort_by = report_dict.get(key) or ""


+ 2
- 2
frappe/print/doctype/print_format/print_format.json View File

@@ -105,7 +105,7 @@
"fieldname": "print_format_help", "fieldname": "print_format_help",
"fieldtype": "HTML", "fieldtype": "HTML",
"label": "Print Format Help", "label": "Print Format Help",
"options": "<h3>Print Format Help</h3>\n<hr>\n<h4>Introduction</h4>\n<p>Print Formats are rendered on the server side using the Jinja Templating Language. All forms have access to the <code>doc</code> object which contains information about the document that is being formatted. You can also access common utilities via the <code>frappe</code> module.</p>\n<p>For styling, the Boostrap CSS framework is provided and you can enjoy the full range of classes.</p>\n<hr>\n<h4>References</h4>\n<ol>\n\t<li><a href=\"http://jinja.pocoo.org/docs/templates/\" target=\"_blank\">Jinja Tempalting Language: Reference</a></li>\n\t<li><a href=\"http://getbootstrap.com\" target=\"_blank\">Bootstrap CSS Framework</a></li>\n</ol>\n<hr>\n<h4>Example</h4>\n<pre><code>&lt;h3&gt;{{ doc.select_print_heading or \"Invoice\" }}&lt;/h3&gt;\n&lt;div class=\"row\"&gt;\n\t&lt;div class=\"col-md-3 text-right\"&gt;Customer Name&lt;/div&gt;\n\t&lt;div class=\"col-md-9\"&gt;{{ doc.customer_name }}&lt;/div&gt;\n&lt;/div&gt;\n&lt;div class=\"row\"&gt;\n\t&lt;div class=\"col-md-3 text-right\"&gt;Date&lt;/div&gt;\n\t&lt;div class=\"col-md-9\"&gt;{{ doc.get_formatted(\"invoice_date\") }}&lt;/div&gt;\n&lt;/div&gt;\n&lt;table class=\"table table-bordered\"&gt;\n\t&lt;tbody&gt;\n\t\t&lt;tr&gt;\n\t\t\t&lt;th&gt;Sr&lt;/th&gt;\n\t\t\t&lt;th&gt;Item Name&lt;/th&gt;\n\t\t\t&lt;th&gt;Description&lt;/th&gt;\n\t\t\t&lt;th class=\"text-right\"&gt;Qty&lt;/th&gt;\n\t\t\t&lt;th class=\"text-right\"&gt;Rate&lt;/th&gt;\n\t\t\t&lt;th class=\"text-right\"&gt;Amount&lt;/th&gt;\n\t\t&lt;/tr&gt;\n\t\t{%- for row in doc.entries -%}\n\t\t&lt;tr&gt;\n\t\t\t&lt;td style=\"width: 3%;\"&gt;{{ row.idx }}&lt;/td&gt;\n\t\t\t&lt;td style=\"width: 20%;\"&gt;\n\t\t\t\t{{ row.item_name }}\n\t\t\t\t{% if row.item_code != row.item_name -%}\n\t\t\t\t&lt;br&gt;Item Code: {{ row.item_code}}\n\t\t\t\t{%- endif %}\n\t\t\t&lt;/td&gt;\n\t\t\t&lt;td style=\"width: 37%;\"&gt;\n\t\t\t\t&lt;div style=\"border: 0px;\"&gt;{{ row.description }}&lt;/div&gt;&lt;/td&gt;\n\t\t\t&lt;td style=\"width: 10%; text-align: right;\"&gt;{{ row.qty }} {{ row.uom or row.stock_uom }}&lt;/td&gt;\n\t\t\t&lt;td style=\"width: 15%; text-align: right;\"&gt;{{\n\t\t\t\trow.get_formatted(\"rate\", doc) }}&lt;/td&gt;\n\t\t\t&lt;td style=\"width: 15%; text-align: right;\"&gt;{{\n\t\t\t\trow.get_formatted(\"amount\", doc) }}&lt;/td&gt;\n\t\t&lt;/tr&gt;\n\t\t{%- endfor -%}\n\t&lt;/tbody&gt;\n&lt;/table&gt;</code></pre>\n<hr>\n<h4>Common Functions</h4>\n<table class=\"table table-bordered\">\n\t<tbody>\n\t\t<tr>\n\t\t\t<td style=\"width: 30%\"><code>doc.get_formatted(\"[fieldname]\", [parent_doc])</code></td>\n\t\t\t<td>Get document value formatted as Date, Currency etc. Pass parent <code>doc</code> for curreny type fields.</td>\n\t\t</tr>\n\t\t<tr>\n\t\t\t<td style=\"width: 30%\"><code>frappe.db.get_value(\"[doctype]\", \"[name]\", \"fieldname\")</code></td>\n\t\t\t<td>Get value from another document.</td>\n\t\t</tr>\n\t</tbody>\n</table>\n",
"options": "<h3>Print Format Help</h3>\n<hr>\n<h4>Introduction</h4>\n<p>Print itemsFormats are rendered on the server side using the Jinja Templating Language. All forms have access to the <code>doc</code> object which contains information about the document that is being formatted. You can also access common utilities via the <code>frappe</code> module.</p>\n<p>For styling, the Boostrap CSS framework is provided and you can enjoy the full range of classes.</p>\n<hr>\n<h4>References</h4>\n<ol>\n\t<li><a href=\"http://jinja.pocoo.org/docs/templates/\" target=\"_blank\">Jinja Tempalting Language: Reference</a></li>\n\t<li><a href=\"http://getbootstrap.com\" target=\"_blank\">Bootstrap CSS Framework</a></li>\n</ol>\n<hr>\n<h4>Example</h4>\n<pre><code>&lt;h3&gt;{{ doc.select_print_heading or \"Invoice\" }}&lt;/h3&gt;\n&lt;div class=\"row\"&gt;\n\t&lt;div class=\"col-md-3 text-right\"&gt;Customer Name&lt;/div&gt;\n\t&lt;div class=\"col-md-9\"&gt;{{ doc.customer_name }}&lt;/div&gt;\n&lt;/div&gt;\n&lt;div class=\"row\"&gt;\n\t&lt;div class=\"col-md-3 text-right\"&gt;Date&lt;/div&gt;\n\t&lt;div class=\"col-md-9\"&gt;{{ doc.get_formatted(\"invoice_date\") }}&lt;/div&gt;\n&lt;/div&gt;\n&lt;table class=\"table table-bordered\"&gt;\n\t&lt;tbody&gt;\n\t\t&lt;tr&gt;\n\t\t\t&lt;th&gt;Sr&lt;/th&gt;\n\t\t\t&lt;th&gt;Item Name&lt;/th&gt;\n\t\t\t&lt;th&gt;Description&lt;/th&gt;\n\t\t\t&lt;th class=\"text-right\"&gt;Qty&lt;/th&gt;\n\t\t\t&lt;th class=\"text-right\"&gt;Rate&lt;/th&gt;\n\t\t\t&lt;th class=\"text-right\"&gt;Amount&lt;/th&gt;\n\t\t&lt;/tr&gt;\n\t\t{%- for row in doc.items -%}\n\t\t&lt;tr&gt;\n\t\t\t&lt;td style=\"width: 3%;\"&gt;{{ row.idx }}&lt;/td&gt;\n\t\t\t&lt;td style=\"width: 20%;\"&gt;\n\t\t\t\t{{ row.item_name }}\n\t\t\t\t{% if row.item_code != row.item_name -%}\n\t\t\t\t&lt;br&gt;Item Code: {{ row.item_code}}\n\t\t\t\t{%- endif %}\n\t\t\t&lt;/td&gt;\n\t\t\t&lt;td style=\"width: 37%;\"&gt;\n\t\t\t\t&lt;div style=\"border: 0px;\"&gt;{{ row.description }}&lt;/div&gt;&lt;/td&gt;\n\t\t\t&lt;td style=\"width: 10%; text-align: right;\"&gt;{{ row.qty }} {{ row.uom or row.stock_uom }}&lt;/td&gt;\n\t\t\t&lt;td style=\"width: 15%; text-align: right;\"&gt;{{\n\t\t\t\trow.get_formatted(\"rate\", doc) }}&lt;/td&gt;\n\t\t\t&lt;td style=\"width: 15%; text-align: right;\"&gt;{{\n\t\t\t\trow.get_formatted(\"amount\", doc) }}&lt;/td&gt;\n\t\t&lt;/tr&gt;\n\t\t{%- endfor -%}\n\t&lt;/tbody&gt;\n&lt;/table&gt;</code></pre>\n<hr>\n<h4>Common Functions</h4>\n<table class=\"table table-bordered\">\n\t<tbody>\n\t\t<tr>\n\t\t\t<td style=\"width: 30%\"><code>doc.get_formatted(\"[fieldname]\", [parent_doc])</code></td>\n\t\t\t<td>Get document value formatted as Date, Currency etc. Pass parent <code>doc</code> for curreny type fields.</td>\n\t\t</tr>\n\t\t<tr>\n\t\t\t<td style=\"width: 30%\"><code>frappe.db.get_value(\"[doctype]\", \"[name]\", \"fieldname\")</code></td>\n\t\t\t<td>Get value from another document.</td>\n\t\t</tr>\n\t</tbody>\n</table>\n",
"permlevel": 0 "permlevel": 0
} }
], ],
@@ -118,7 +118,7 @@
"issingle": 0, "issingle": 0,
"istable": 0, "istable": 0,
"max_attachments": 0, "max_attachments": 0,
"modified": "2014-07-31 03:39:35.898712",
"modified": "2014-12-25 03:39:35.898712",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Print", "module": "Print",
"name": "Print Format", "name": "Print Format",


+ 1
- 1
frappe/public/js/frappe/form/grid.js View File

@@ -425,7 +425,7 @@ frappe.ui.form.GridRow = Class.extend({
this.form_panel.toggle(true); this.form_panel.toggle(true);
if(this.frm.doc.docstatus===0) { if(this.frm.doc.docstatus===0) {
var first = this.form_area.find(":input:first"); var first = this.form_area.find(":input:first");
if(first.length && first.attr("data-fieldtype")!="Date") {
if(first.length && !in_list(["Date", "Datetime", "Time"], first.attr("data-fieldtype"))) {
try { try {
first.get(0).focus(); first.get(0).focus();
} catch(e) { } catch(e) {


+ 5
- 5
frappe/public/js/frappe/model/workflow.js View File

@@ -23,18 +23,18 @@ frappe.workflow = {
}, },
get_default_state: function(doctype) { get_default_state: function(doctype) {
frappe.workflow.setup(doctype); frappe.workflow.setup(doctype);
return frappe.workflow.workflows[doctype].workflow_document_states[0].state;
return frappe.workflow.workflows[doctype].states[0].state;
}, },
get_transitions: function(doctype, state) { get_transitions: function(doctype, state) {
frappe.workflow.setup(doctype); frappe.workflow.setup(doctype);
return frappe.get_children(frappe.workflow.workflows[doctype], "workflow_transitions", {state:state});
return frappe.get_children(frappe.workflow.workflows[doctype], "transitions", {state:state});
}, },
get_document_state: function(doctype, state) { get_document_state: function(doctype, state) {
frappe.workflow.setup(doctype); frappe.workflow.setup(doctype);
return frappe.get_children(frappe.workflow.workflows[doctype], "workflow_document_states", {state:state})[0];
return frappe.get_children(frappe.workflow.workflows[doctype], "states", {state:state})[0];
}, },
get_next_state: function(doctype, state, action) { get_next_state: function(doctype, state, action) {
return frappe.get_children(frappe.workflow.workflows[doctype], "workflow_transitions", {
return frappe.get_children(frappe.workflow.workflows[doctype], "transitions", {
state:state, action:action})[0].next_state; state:state, action:action})[0].next_state;
}, },
is_read_only: function(doctype, name) { is_read_only: function(doctype, name) {
@@ -57,7 +57,7 @@ frappe.workflow = {
return false; return false;
}, },
get_update_fields: function(doctype) { get_update_fields: function(doctype) {
var update_fields = $.unique($.map(frappe.workflow.workflows[doctype].workflow_document_states || [],
var update_fields = $.unique($.map(frappe.workflow.workflows[doctype].states || [],
function(d) { function(d) {
return d.update_field; return d.update_field;
})); }));


+ 1
- 1
frappe/tests/test_client_login.py View File

@@ -21,7 +21,7 @@ from frappe.utils import sel


# def test_material_request(self): # def test_material_request(self):
# sel.new_doc("Stock", "Material Request") # sel.new_doc("Stock", "Material Request")
# sel.add_child("indent_details")
# sel.add_child("items")
# sel.set_field("item_code", "_Test Item") # sel.set_field("item_code", "_Test Item")
# sel.set_field("schedule_date", "10-10-2014") # sel.set_field("schedule_date", "10-10-2014")
# sel.primary_action() # sel.primary_action()


+ 1
- 1
frappe/tests/test_data_import.py View File

@@ -83,4 +83,4 @@ class TestDataImport(unittest.TestCase):
importer.upload(content) importer.upload(content)


ev = frappe.get_doc("Event", {"subject":"__Test Event"}) ev = frappe.get_doc("Event", {"subject":"__Test Event"})
self.assertTrue("Administrator" in [d.person for d in ev.event_individuals])
self.assertTrue("Administrator" in [d.person for d in ev.users])

+ 2
- 2
frappe/tests/test_document.py View File

@@ -45,7 +45,7 @@ class TestDocument(unittest.TestCase):
"subject":"test-doc-test-event 2", "subject":"test-doc-test-event 2",
"starts_on": "2014-01-01", "starts_on": "2014-01-01",
"event_type": "Public", "event_type": "Public",
"event_individuals": [
"users": [
{ {
"person": "Administrator" "person": "Administrator"
} }
@@ -57,7 +57,7 @@ class TestDocument(unittest.TestCase):
"test-doc-test-event 2") "test-doc-test-event 2")


d1 = frappe.get_doc("Event", d.name) d1 = frappe.get_doc("Event", d.name)
self.assertTrue(d1.event_individuals[0].person, "Administrator")
self.assertTrue(d1.users[0].person, "Administrator")


def test_update(self): def test_update(self):
d = self.test_insert() d = self.test_insert()


+ 1
- 0
frappe/utils/pdf.py View File

@@ -17,6 +17,7 @@ def get_pdf(html, options=None):
'margin-bottom': '15mm', 'margin-bottom': '15mm',
'margin-left': '15mm', 'margin-left': '15mm',
'encoding': "UTF-8", 'encoding': "UTF-8",
'quiet': None,
'no-outline': None 'no-outline': None
}) })




+ 6
- 0
frappe/workflow/doctype/workflow/test_records.json View File

@@ -0,0 +1,6 @@
[
{
"doctype": "Workflow",
"name": "_Test Workflow 1"
}
]

+ 10
- 0
frappe/workflow/doctype/workflow/test_workflow.py View File

@@ -0,0 +1,10 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
# See license.txt

import frappe
import unittest

test_records = frappe.get_test_records('Workflow')

class TestWorkflow(unittest.TestCase):
pass

+ 11
- 7
frappe/workflow/doctype/workflow/workflow.json View File

@@ -1,6 +1,6 @@
{ {
"autoname": "field:workflow_name", "autoname": "field:workflow_name",
"creation": "2012-12-28 10:49:55.000000",
"creation": "2012-12-28 10:49:55",
"description": "Defines workflow states and rules for a document.", "description": "Defines workflow states and rules for a document.",
"docstatus": 0, "docstatus": 0,
"doctype": "DocType", "doctype": "DocType",
@@ -9,6 +9,7 @@
{ {
"fieldname": "workflow_name", "fieldname": "workflow_name",
"fieldtype": "Data", "fieldtype": "Data",
"in_list_view": 1,
"label": "Workflow Name", "label": "Workflow Name",
"permlevel": 0, "permlevel": 0,
"read_only": 0, "read_only": 0,
@@ -18,6 +19,7 @@
"description": "DocType on which this Workflow is applicable.", "description": "DocType on which this Workflow is applicable.",
"fieldname": "document_type", "fieldname": "document_type",
"fieldtype": "Link", "fieldtype": "Link",
"in_list_view": 1,
"label": "Document Type", "label": "Document Type",
"options": "DocType", "options": "DocType",
"permlevel": 0, "permlevel": 0,
@@ -27,6 +29,7 @@
"description": "If checked, all other workflows become inactive.", "description": "If checked, all other workflows become inactive.",
"fieldname": "is_active", "fieldname": "is_active",
"fieldtype": "Check", "fieldtype": "Check",
"in_list_view": 1,
"label": "Is Active", "label": "Is Active",
"permlevel": 0 "permlevel": 0
}, },
@@ -39,9 +42,9 @@
}, },
{ {
"description": "All possible Workflow States and roles of the workflow. <br>Docstatus Options: 0 is\"Saved\", 1 is \"Submitted\" and 2 is \"Cancelled\"", "description": "All possible Workflow States and roles of the workflow. <br>Docstatus Options: 0 is\"Saved\", 1 is \"Submitted\" and 2 is \"Cancelled\"",
"fieldname": "workflow_document_states",
"fieldname": "states",
"fieldtype": "Table", "fieldtype": "Table",
"label": "Workflow Document States",
"label": "Document States",
"options": "Workflow Document State", "options": "Workflow Document State",
"permlevel": 0, "permlevel": 0,
"reqd": 1 "reqd": 1
@@ -55,9 +58,9 @@
}, },
{ {
"description": "Rules defining transition of state in the workflow.", "description": "Rules defining transition of state in the workflow.",
"fieldname": "workflow_transitions",
"fieldname": "transitions",
"fieldtype": "Table", "fieldtype": "Table",
"label": "Workflow Transitions",
"label": "Transitions",
"options": "Workflow Transition", "options": "Workflow Transition",
"permlevel": 0, "permlevel": 0,
"reqd": 1 "reqd": 1
@@ -73,14 +76,14 @@
], ],
"icon": "icon-random", "icon": "icon-random",
"idx": 1, "idx": 1,
"modified": "2014-01-20 17:49:35.000001",
"modified": "2014-12-26 16:53:17.720709",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Workflow", "module": "Workflow",
"name": "Workflow", "name": "Workflow",
"owner": "Administrator", "owner": "Administrator",
"permissions": [ "permissions": [
{ {
"cancel": 1,
"cancel": 0,
"create": 1, "create": 1,
"delete": 1, "delete": 1,
"email": 1, "email": 1,
@@ -88,6 +91,7 @@
"print": 1, "print": 1,
"read": 1, "read": 1,
"role": "System Manager", "role": "System Manager",
"submit": 0,
"write": 1 "write": 1
} }
] ]


+ 3
- 3
frappe/workflow/doctype/workflow/workflow.py View File

@@ -39,7 +39,7 @@ class Workflow(Document):


def update_default_workflow_status(self): def update_default_workflow_status(self):
docstatus_map = {} docstatus_map = {}
states = self.get("workflow_document_states")
states = self.get("states")
for d in states: for d in states:
if not d.doc_status in docstatus_map: if not d.doc_status in docstatus_map:
frappe.db.sql("""update `tab%s` set `%s` = %s where \ frappe.db.sql("""update `tab%s` set `%s` = %s where \
@@ -49,13 +49,13 @@ class Workflow(Document):


def validate_docstatus(self): def validate_docstatus(self):
def get_state(state): def get_state(state):
for s in self.workflow_document_states:
for s in self.states:
if s.state==state: if s.state==state:
return s return s


frappe.throw(frappe._("{0} not a valid State").format(state)) frappe.throw(frappe._("{0} not a valid State").format(state))


for t in self.workflow_transitions:
for t in self.transitions:
state = get_state(t.state) state = get_state(t.state)
next_state = get_state(t.next_state) next_state = get_state(t.next_state)




Loading…
Cancel
Save