@@ -11,6 +11,9 @@ class DocType: | |||||
def validate(self): | def validate(self): | ||||
"""only administrator can save standard report""" | """only administrator can save standard report""" | ||||
if not self.doc.module: | |||||
self.doc.module = frappe.db.get_value("DocType", self.doc.ref_doctype, "module") | |||||
if not self.doc.is_standard: | if not self.doc.is_standard: | ||||
self.doc.is_standard = "No" | self.doc.is_standard = "No" | ||||
if frappe.session.user=="Administrator" and getattr(conf, 'developer_mode',0)==1: | if frappe.session.user=="Administrator" and getattr(conf, 'developer_mode',0)==1: | ||||
@@ -24,7 +27,7 @@ class DocType: | |||||
and frappe.session.user!="Administrator": | and frappe.session.user!="Administrator": | ||||
frappe.msgprint(_("Only Administrator allowed to create Query / Script Reports"), | frappe.msgprint(_("Only Administrator allowed to create Query / Script Reports"), | ||||
raise_exception=True) | raise_exception=True) | ||||
def on_update(self): | def on_update(self): | ||||
self.export_doc() | self.export_doc() | ||||
@@ -32,4 +35,4 @@ class DocType: | |||||
from frappe.modules.export_file import export_to_files | from frappe.modules.export_file import export_to_files | ||||
if self.doc.is_standard == 'Yes' and (conf.get('developer_mode') or 0) == 1: | if self.doc.is_standard == 'Yes' and (conf.get('developer_mode') or 0) == 1: | ||||
export_to_files(record_list=[['Report', self.doc.name]], | export_to_files(record_list=[['Report', self.doc.name]], | ||||
record_module=frappe.db.get_value("DocType", self.doc.ref_doctype, "module")) | |||||
record_module=self.doc.module) |
@@ -2,7 +2,7 @@ | |||||
{ | { | ||||
"creation": "2013-03-09 15:45:57", | "creation": "2013-03-09 15:45:57", | ||||
"docstatus": 0, | "docstatus": 0, | ||||
"modified": "2014-01-20 17:49:17", | |||||
"modified": "2014-03-07 15:20:02", | |||||
"modified_by": "Administrator", | "modified_by": "Administrator", | ||||
"owner": "Administrator" | "owner": "Administrator" | ||||
}, | }, | ||||
@@ -126,6 +126,13 @@ | |||||
"label": "JSON", | "label": "JSON", | ||||
"read_only": 1 | "read_only": 1 | ||||
}, | }, | ||||
{ | |||||
"doctype": "DocField", | |||||
"fieldname": "module", | |||||
"fieldtype": "Link", | |||||
"label": "Module", | |||||
"options": "Module Def" | |||||
}, | |||||
{ | { | ||||
"create": 1, | "create": 1, | ||||
"delete": 1, | "delete": 1, | ||||
@@ -2,13 +2,14 @@ | |||||
{ | { | ||||
"creation": "2013-02-25 14:26:30", | "creation": "2013-02-25 14:26:30", | ||||
"docstatus": 0, | "docstatus": 0, | ||||
"modified": "2013-02-25 14:26:51", | |||||
"modified": "2014-03-07 15:30:27", | |||||
"modified_by": "Administrator", | "modified_by": "Administrator", | ||||
"owner": "Administrator" | "owner": "Administrator" | ||||
}, | }, | ||||
{ | { | ||||
"doctype": "Report", | "doctype": "Report", | ||||
"is_standard": "Yes", | "is_standard": "Yes", | ||||
"module": "Core", | |||||
"name": "__common__", | "name": "__common__", | ||||
"ref_doctype": "ToDo", | "ref_doctype": "ToDo", | ||||
"report_name": "ToDo", | "report_name": "ToDo", | ||||
@@ -190,7 +190,8 @@ class Bean: | |||||
if self.doc.fields.get("__islocal"): | if self.doc.fields.get("__islocal"): | ||||
# set name before validate | # set name before validate | ||||
self.doc.set_new_name(self.get_controller()) | |||||
self.run_method('before_set_name') | |||||
self.doc.set_new_name(self) | |||||
self.run_method('before_insert') | self.run_method('before_insert') | ||||
if method != "cancel": | if method != "cancel": | ||||
@@ -229,21 +230,19 @@ class Bean: | |||||
def add_to_response(out, new_response): | def add_to_response(out, new_response): | ||||
if isinstance(new_response, dict): | if isinstance(new_response, dict): | ||||
print self.doc.doctype, self.doc.name, method | |||||
print "add to response", new_response | |||||
out.update(new_response) | out.update(new_response) | ||||
if hasattr(self.controller, method): | if hasattr(self.controller, method): | ||||
add_to_response(frappe.local.response, | add_to_response(frappe.local.response, | ||||
frappe.call(getattr(self.controller, method), *args, **kwargs)) | frappe.call(getattr(self.controller, method), *args, **kwargs)) | ||||
self.set_doclist(self.controller.doclist) | |||||
args = [self, method] + list(args) | args = [self, method] + list(args) | ||||
for handler in frappe.get_hooks("bean_event:" + self.doc.doctype + ":" + method) \ | for handler in frappe.get_hooks("bean_event:" + self.doc.doctype + ":" + method) \ | ||||
+ frappe.get_hooks("bean_event:*:" + method): | + frappe.get_hooks("bean_event:*:" + method): | ||||
add_to_response(frappe.local.response, frappe.call(frappe.get_attr(handler), *args, **kwargs)) | add_to_response(frappe.local.response, frappe.call(frappe.get_attr(handler), *args, **kwargs)) | ||||
self.set_doclist(self.controller.doclist) | |||||
return frappe.local.response | return frappe.local.response | ||||
def get_attr(self, method): | def get_attr(self, method): | ||||
@@ -244,7 +244,7 @@ class Document: | |||||
self.name = am_prefix + '-' + str(am_id) | self.name = am_prefix + '-' + str(am_id) | ||||
def set_new_name(self, controller=None): | |||||
def set_new_name(self, bean=None): | |||||
if self._new_name_set: | if self._new_name_set: | ||||
# already set by bean | # already set by bean | ||||
return | return | ||||
@@ -264,12 +264,13 @@ class Document: | |||||
# by method | # by method | ||||
else: | else: | ||||
# get my object | # get my object | ||||
if not controller: | |||||
controller = frappe.get_obj([self]) | |||||
if hasattr(controller, 'autoname'): | |||||
return controller.autoname() | |||||
if not bean: | |||||
bean = frappe.bean([self]) | |||||
bean.run_method("autoname") | |||||
if self.name: | |||||
return | |||||
# based on a field | # based on a field | ||||
if autoname and autoname.startswith('field:'): | if autoname and autoname.startswith('field:'): | ||||
n = self.fields[autoname[6:]] | n = self.fields[autoname[6:]] | ||||
@@ -19,3 +19,4 @@ frappe.patches.4_0.rename_sitemap_to_route | |||||
frappe.patches.4_0.set_website_route_idx | frappe.patches.4_0.set_website_route_idx | ||||
execute:import frappe.installer;frappe.installer.make_site_dirs() #2014-02-19 | execute:import frappe.installer;frappe.installer.make_site_dirs() #2014-02-19 | ||||
frappe.patches.4_0.private_backups | frappe.patches.4_0.private_backups | ||||
frappe.patches.4_0.set_module_in_report |
@@ -0,0 +1,9 @@ | |||||
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors | |||||
# MIT License. See license.txt | |||||
from __future__ import unicode_literals | |||||
import frappe | |||||
def execute(): | |||||
frappe.db.sql("""update `tabReport` r set r.module=(select d.module from `tabDocType` d | |||||
where d.name=r.ref_doctype) where ifnull(r.module, '')=''""") |
@@ -164,14 +164,13 @@ def get_doctype_count_from_table(doctype): | |||||
def get_report_list(module, is_standard="No"): | def get_report_list(module, is_standard="No"): | ||||
"""return list on new style reports for modules""" | """return list on new style reports for modules""" | ||||
return frappe.db.sql(""" | return frappe.db.sql(""" | ||||
select distinct "report" as type, tabReport.name, tabReport.ref_doctype as doctype, | |||||
if((tabReport.report_type='Query Report' or | |||||
tabReport.report_type='Script Report'), 1, 0) as is_query_report, | |||||
select distinct "report" as type, name, ref_doctype as doctype, | |||||
if((report_type='Query Report' or | |||||
report_type='Script Report'), 1, 0) as is_query_report, | |||||
report_type as description | report_type as description | ||||
from `tabReport`, `tabDocType` | |||||
where tabDocType.module=%s | |||||
and tabDocType.name = tabReport.ref_doctype | |||||
and tabReport.docstatus in (0, NULL) | |||||
and ifnull(tabReport.is_standard, "No")=%s | |||||
and ifnull(tabReport.disabled,0) != 1 | |||||
order by tabReport.name""", (module, is_standard), as_dict=True) | |||||
from `tabReport` | |||||
where module=%s | |||||
and docstatus in (0, NULL) | |||||
and ifnull(is_standard, "No")=%s | |||||
and ifnull(disabled,0) != 1 | |||||
order by name""", (module, is_standard), as_dict=True) |