Merge pull request #3693 from rmehta/close-task

[minor] close button for task and item not found error fix
This commit is contained in:
Anand Doshi 2015-07-20 12:56:50 +05:30
commit a9a284a5ae
2 changed files with 50 additions and 28 deletions

View File

@ -5,42 +5,59 @@ frappe.provide("erpnext.projects");
cur_frm.add_fetch("project", "company", "company");
erpnext.projects.Task = frappe.ui.form.Controller.extend({
setup: function() {
this.frm.fields_dict.project.get_query = function() {
frappe.ui.form.on("Task", {
refresh: function(frm) {
var doc = frm.doc;
if(!doc.__islocal) {
if(frappe.model.can_read("Time Log")) {
frm.add_custom_button(__("Time Logs"), function() {
frappe.route_options = {"project": doc.project, "task": doc.name}
frappe.set_route("List", "Time Log");
}, "icon-list", true);
}
if(frappe.model.can_read("Expense Claim")) {
frm.add_custom_button(__("Expense Claims"), function() {
frappe.route_options = {"project": doc.project, "task": doc.name}
frappe.set_route("List", "Expense Claim");
}, "icon-list", true);
}
if(frm.perm[0].write) {
if(frm.doc.status==="Open") {
frm.add_custom_button("Close", function() {
frm.set_value("status", "Closed");
frm.save();
});
} else {
frm.add_custom_button("Reopen", function() {
frm.set_value("status", "Open");
frm.save();
});
}
}
}
},
setup: function(frm) {
frm.fields_dict.project.get_query = function() {
return {
query: "erpnext.projects.doctype.task.task.get_project"
}
};
},
project: function() {
if(this.frm.doc.project) {
return get_server_fields('get_project_details', '','', this.frm.doc, this.frm.doc.doctype,
this.frm.doc.name, 1);
project: function(frm) {
if(frm.doc.project) {
return get_server_fields('get_project_details', '','', frm.doc, frm.doc.doctype,
frm.doc.name, 1);
}
},
validate: function() {
this.frm.doc.project && frappe.model.remove_from_locals("Project",
this.frm.doc.project);
validate: function(frm) {
frm.doc.project && frappe.model.remove_from_locals("Project",
frm.doc.project);
},
refresh: function(doc) {
if(!doc.__islocal) {
cur_frm.add_custom_button(__("Time Logs"), function() {
frappe.route_options = {"project": doc.project, "task": doc.name}
frappe.set_route("List", "Time Log");
}, "icon-list", true);
cur_frm.add_custom_button(__("Expense Claims"), function() {
frappe.route_options = {"project": doc.project, "task": doc.name}
frappe.set_route("List", "Expense Claim");
}, "icon-list", true);
}
}
});
cur_frm.add_fetch('task', 'subject', 'subject');
cur_frm.cscript = new erpnext.projects.Task({frm: cur_frm});

View File

@ -57,7 +57,12 @@ class StockLedgerEntry(Document):
def validate_item(self):
item_det = frappe.db.sql("""select name, has_batch_no, docstatus,
is_stock_item, has_variants, stock_uom
from tabItem where name=%s""", self.item_code, as_dict=True)[0]
from tabItem where name=%s""", self.item_code, as_dict=True)
if not item_det:
frappe.throw(_("Item {0} not found").format(self.item_code))
item_det = item_det[0]
if item_det.is_stock_item != 'Yes':
frappe.throw(_("Item {0} must be a stock Item").format(self.item_code))
@ -97,7 +102,7 @@ class StockLedgerEntry(Document):
def scrub_posting_time(self):
if not self.posting_time or self.posting_time == '00:0':
self.posting_time = '00:00'
def validate_batch(self):
if self.batch_no and self.voucher_type != "Stock Entry":
expiry_date = frappe.db.get_value("Batch", self.batch_no, "expiry_date")