Merge branch 'master' of github.com:webnotes/erpnext

This commit is contained in:
Nabin Hait
2013-05-10 10:48:56 +05:30
4 changed files with 40 additions and 7 deletions

View File

@@ -1,5 +1,9 @@
$.extend(cur_frm.cscript, { wn.provide("erpnext.projects");
refresh: function(doc) {
erpnext.projects.TimeLog = wn.ui.form.Controller.extend({
setup: function() {
this.frm.set_query("task", erpnext.queries.task);
} }
}); });
cur_frm.cscript = new erpnext.projects.TimeLog({frm: cur_frm});

View File

@@ -6,3 +6,18 @@ import webnotes
@webnotes.whitelist() @webnotes.whitelist()
def get_time_log_list(doctype, txt, searchfield, start, page_len, filters): def get_time_log_list(doctype, txt, searchfield, start, page_len, filters):
return webnotes.conn.get_values("Time Log", filters, ["name", "activity_type", "owner"]) return webnotes.conn.get_values("Time Log", filters, ["name", "activity_type", "owner"])
@webnotes.whitelist()
def query_task(doctype, txt, searchfield, start, page_len, filters):
search_string = "%%%s%%" % txt
order_by_string = "%s%%" % txt
return webnotes.conn.sql("""select name, subject from `tabTask`
where `%s` like %s or `subject` like %s
order by
case when `subject` like %s then 0 else 1 end,
case when `%s` like %s then 0 else 1 end,
`%s`,
subject
limit %s, %s""" %
(searchfield, "%s", "%s", "%s", searchfield, "%s", searchfield, "%s", "%s"),
(search_string, search_string, order_by_string, order_by_string, start, page_len))

View File

@@ -161,3 +161,7 @@ erpnext.queries.bom = function(opts) {
+ " LIMIT 50" + " LIMIT 50"
} }
erpnext.queries.task = function() {
return { query: "projects.utils.query_task" };
};

View File

@@ -104,7 +104,17 @@ cur_frm.cscript['Create Customer'] = function(){
'from_to_list':"[['Lead', 'Customer']]" 'from_to_list':"[['Lead', 'Customer']]"
}, },
function(r,rt) { function(r,rt) {
loaddoc("Customer", n); wn.model.with_doctype("Customer", function() {
var customer = wn.model.get_doc("Customer", n);
var customer_copy = $.extend({}, customer);
var updated = wn.model.set_default_values(customer_copy);
$.each(updated, function(i, f) {
if(!customer[f]) customer[f] = customer_copy[f];
});
loaddoc("Customer", n);
});
} }
); );
} }