[fix] [issue] webnotes/erpnext#1191 - set expected delivery date in production order
This commit is contained in:
parent
d94bab0e1d
commit
2678ed181a
@ -1,28 +1,56 @@
|
|||||||
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
||||||
// License: GNU General Public License v3. See license.txt
|
// License: GNU General Public License v3. See license.txt
|
||||||
|
|
||||||
cur_frm.cscript.onload = function(doc, dt, dn) {
|
$.extend(cur_frm.cscript, {
|
||||||
|
onload: function (doc, dt, dn) {
|
||||||
|
|
||||||
if (!doc.status) doc.status = 'Draft';
|
if (!doc.status) doc.status = 'Draft';
|
||||||
cfn_set_fields(doc, dt, dn);
|
cfn_set_fields(doc, dt, dn);
|
||||||
}
|
|
||||||
|
|
||||||
cur_frm.cscript.refresh = function(doc, dt, dn) {
|
this.frm.add_fetch("sales_order", "delivery_date", "expected_delivery_date");
|
||||||
cur_frm.dashboard.reset();
|
},
|
||||||
|
|
||||||
|
refresh: function(doc, dt, dn) {
|
||||||
|
this.frm.dashboard.reset();
|
||||||
erpnext.hide_naming_series();
|
erpnext.hide_naming_series();
|
||||||
cur_frm.set_intro("");
|
this.frm.set_intro("");
|
||||||
cfn_set_fields(doc, dt, dn);
|
cfn_set_fields(doc, dt, dn);
|
||||||
|
|
||||||
if(doc.docstatus===0 && !doc.__islocal) {
|
if (doc.docstatus === 0 && !doc.__islocal) {
|
||||||
cur_frm.set_intro(wn._("Submit this Production Order for further processing."));
|
this.frm.set_intro(wn._("Submit this Production Order for further processing."));
|
||||||
} else if(doc.docstatus===1) {
|
} else if (doc.docstatus === 1) {
|
||||||
var percent = flt(doc.produced_qty) / flt(doc.qty) * 100;
|
var percent = flt(doc.produced_qty) / flt(doc.qty) * 100;
|
||||||
cur_frm.dashboard.add_progress(cint(percent) + "% " + wn._("Complete"), percent);
|
this.frm.dashboard.add_progress(cint(percent) + "% " + wn._("Complete"), percent);
|
||||||
|
|
||||||
if(doc.status === "Stopped") {
|
if(doc.status === "Stopped") {
|
||||||
cur_frm.dashboard.set_headline_alert(wn._("Stopped"), "alert-danger", "icon-stop");
|
this.frm.dashboard.set_headline_alert(wn._("Stopped"), "alert-danger", "icon-stop");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
|
||||||
|
production_item: function(doc) {
|
||||||
|
return this.frm.call({
|
||||||
|
method: "get_item_details",
|
||||||
|
args: { item: doc.production_item }
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
make_se: function(purpose) {
|
||||||
|
var me = this;
|
||||||
|
|
||||||
|
wn.call({
|
||||||
|
method:"manufacturing.doctype.production_order.production_order.make_stock_entry",
|
||||||
|
args: {
|
||||||
|
"production_order_id": me.frm.doc.name,
|
||||||
|
"purpose": purpose
|
||||||
|
},
|
||||||
|
callback: function(r) {
|
||||||
|
var doclist = wn.model.sync(r.message);
|
||||||
|
wn.set_route("Form", doclist[0].doctype, doclist[0].name);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
var cfn_set_fields = function(doc, dt, dn) {
|
var cfn_set_fields = function(doc, dt, dn) {
|
||||||
if (doc.docstatus == 1) {
|
if (doc.docstatus == 1) {
|
||||||
@ -38,13 +66,6 @@ var cfn_set_fields = function(doc, dt, dn) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cur_frm.cscript.production_item = function(doc) {
|
|
||||||
return cur_frm.call({
|
|
||||||
method: "get_item_details",
|
|
||||||
args: { item: doc.production_item }
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
cur_frm.cscript['Stop Production Order'] = function() {
|
cur_frm.cscript['Stop Production Order'] = function() {
|
||||||
var doc = cur_frm.doc;
|
var doc = cur_frm.doc;
|
||||||
var check = confirm(wn._("Do you really want to stop production order: " + doc.name));
|
var check = confirm(wn._("Do you really want to stop production order: " + doc.name));
|
||||||
@ -68,20 +89,6 @@ cur_frm.cscript['Update Finished Goods'] = function() {
|
|||||||
cur_frm.cscript.make_se('Manufacture/Repack');
|
cur_frm.cscript.make_se('Manufacture/Repack');
|
||||||
}
|
}
|
||||||
|
|
||||||
cur_frm.cscript.make_se = function(purpose) {
|
|
||||||
wn.call({
|
|
||||||
method:"manufacturing.doctype.production_order.production_order.make_stock_entry",
|
|
||||||
args: {
|
|
||||||
"production_order_id": cur_frm.doc.name,
|
|
||||||
"purpose": purpose
|
|
||||||
},
|
|
||||||
callback: function(r) {
|
|
||||||
var doclist = wn.model.sync(r.message);
|
|
||||||
wn.set_route("Form", doclist[0].doctype, doclist[0].name);
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
cur_frm.fields_dict['production_item'].get_query = function(doc) {
|
cur_frm.fields_dict['production_item'].get_query = function(doc) {
|
||||||
return {
|
return {
|
||||||
filters:[
|
filters:[
|
||||||
@ -98,7 +105,6 @@ cur_frm.fields_dict['project_name'].get_query = function(doc, dt, dn) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
cur_frm.set_query("bom_no", function(doc) {
|
cur_frm.set_query("bom_no", function(doc) {
|
||||||
if (doc.production_item) {
|
if (doc.production_item) {
|
||||||
return{
|
return{
|
||||||
|
|||||||
@ -8,7 +8,6 @@ from webnotes.utils import cstr, flt, nowdate
|
|||||||
from webnotes.model.code import get_obj
|
from webnotes.model.code import get_obj
|
||||||
from webnotes import msgprint, _
|
from webnotes import msgprint, _
|
||||||
|
|
||||||
|
|
||||||
class OverProductionError(webnotes.ValidationError): pass
|
class OverProductionError(webnotes.ValidationError): pass
|
||||||
|
|
||||||
class DocType:
|
class DocType:
|
||||||
@ -37,15 +36,20 @@ class DocType:
|
|||||||
and is_active=1 and item=%s"""
|
and is_active=1 and item=%s"""
|
||||||
, (self.doc.bom_no, self.doc.production_item), as_dict =1)
|
, (self.doc.bom_no, self.doc.production_item), as_dict =1)
|
||||||
if not bom:
|
if not bom:
|
||||||
msgprint("""Incorrect BOM: %s entered.
|
webnotes.throw("""Incorrect BOM: %s entered.
|
||||||
May be BOM not exists or inactive or not submitted
|
May be BOM not exists or inactive or not submitted
|
||||||
or for some other item.""" % cstr(self.doc.bom_no), raise_exception=1)
|
or for some other item.""" % cstr(self.doc.bom_no))
|
||||||
|
|
||||||
def validate_sales_order(self):
|
def validate_sales_order(self):
|
||||||
if self.doc.sales_order:
|
if self.doc.sales_order:
|
||||||
if not webnotes.conn.sql("""select name from `tabSales Order`
|
so = webnotes.conn.sql("""select name, delivery_date from `tabSales Order`
|
||||||
where name=%s and docstatus = 1""", self.doc.sales_order):
|
where name=%s and docstatus = 1""", self.doc.sales_order, as_dict=1)[0]
|
||||||
msgprint("Sales Order: %s is not valid" % self.doc.sales_order, raise_exception=1)
|
|
||||||
|
if not so.name:
|
||||||
|
webnotes.throw("Sales Order: %s is not valid" % self.doc.sales_order)
|
||||||
|
|
||||||
|
if not self.doc.expected_delivery_date:
|
||||||
|
self.doc.expected_delivery_date = so.delivery_date
|
||||||
|
|
||||||
self.validate_production_order_against_so()
|
self.validate_production_order_against_so()
|
||||||
|
|
||||||
@ -76,11 +80,11 @@ class DocType:
|
|||||||
so_qty = flt(so_item_qty) + flt(dnpi_qty)
|
so_qty = flt(so_item_qty) + flt(dnpi_qty)
|
||||||
|
|
||||||
if total_qty > so_qty:
|
if total_qty > so_qty:
|
||||||
webnotes.msgprint(_("Total production order qty for item") + ": " +
|
webnotes.throw(_("Total production order qty for item") + ": " +
|
||||||
cstr(self.doc.production_item) + _(" against sales order") + ": " +
|
cstr(self.doc.production_item) + _(" against sales order") + ": " +
|
||||||
cstr(self.doc.sales_order) + _(" will be ") + cstr(total_qty) + ", " +
|
cstr(self.doc.sales_order) + _(" will be ") + cstr(total_qty) + ", " +
|
||||||
_("which is greater than sales order qty ") + "(" + cstr(so_qty) + ")" +
|
_("which is greater than sales order qty ") + "(" + cstr(so_qty) + ")" +
|
||||||
_("Please reduce qty."), raise_exception=OverProductionError)
|
_("Please reduce qty."), exc=OverProductionError)
|
||||||
|
|
||||||
def stop_unstop(self, status):
|
def stop_unstop(self, status):
|
||||||
""" Called from client side on Stop/Unstop event"""
|
""" Called from client side on Stop/Unstop event"""
|
||||||
@ -114,8 +118,8 @@ class DocType:
|
|||||||
stock_entry = webnotes.conn.sql("""select name from `tabStock Entry`
|
stock_entry = webnotes.conn.sql("""select name from `tabStock Entry`
|
||||||
where production_order = %s and docstatus = 1""", self.doc.name)
|
where production_order = %s and docstatus = 1""", self.doc.name)
|
||||||
if stock_entry:
|
if stock_entry:
|
||||||
msgprint("""Submitted Stock Entry %s exists against this production order.
|
webnotes.throw("""Submitted Stock Entry %s exists against this production order.
|
||||||
Hence can not be cancelled.""" % stock_entry[0][0], raise_exception=1)
|
Hence can not be cancelled.""" % stock_entry[0][0])
|
||||||
|
|
||||||
webnotes.conn.set(self.doc,'status', 'Cancelled')
|
webnotes.conn.set(self.doc,'status', 'Cancelled')
|
||||||
self.update_planned_qty(-self.doc.qty)
|
self.update_planned_qty(-self.doc.qty)
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
{
|
{
|
||||||
"creation": "2013-01-10 16:34:16",
|
"creation": "2013-01-10 16:34:16",
|
||||||
"docstatus": 0,
|
"docstatus": 0,
|
||||||
"modified": "2013-11-02 14:05:44",
|
"modified": "2013-12-18 13:22:14",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"owner": "Administrator"
|
"owner": "Administrator"
|
||||||
},
|
},
|
||||||
@ -136,6 +136,14 @@
|
|||||||
"oldfieldtype": "Currency",
|
"oldfieldtype": "Currency",
|
||||||
"read_only": 1
|
"read_only": 1
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"depends_on": "sales_order",
|
||||||
|
"doctype": "DocField",
|
||||||
|
"fieldname": "expected_delivery_date",
|
||||||
|
"fieldtype": "Date",
|
||||||
|
"label": "Expected Delivery Date",
|
||||||
|
"read_only": 1
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"doctype": "DocField",
|
"doctype": "DocField",
|
||||||
"fieldname": "warehouses",
|
"fieldname": "warehouses",
|
||||||
|
|||||||
@ -186,7 +186,6 @@ class DocType:
|
|||||||
else :
|
else :
|
||||||
msgprint(_("No Production Order created."))
|
msgprint(_("No Production Order created."))
|
||||||
|
|
||||||
|
|
||||||
def get_distinct_items_and_boms(self):
|
def get_distinct_items_and_boms(self):
|
||||||
""" Club similar BOM and item for processing
|
""" Club similar BOM and item for processing
|
||||||
bom_dict {
|
bom_dict {
|
||||||
|
|||||||
@ -258,4 +258,5 @@ patch_list = [
|
|||||||
"execute:webnotes.delete_doc('Report', 'Stock Ledger') #2013-11-29",
|
"execute:webnotes.delete_doc('Report', 'Stock Ledger') #2013-11-29",
|
||||||
"execute:webnotes.delete_doc('Report', 'Payment Collection With Ageing')",
|
"execute:webnotes.delete_doc('Report', 'Payment Collection With Ageing')",
|
||||||
"execute:webnotes.delete_doc('Report', 'Payment Made With Ageing')",
|
"execute:webnotes.delete_doc('Report', 'Payment Made With Ageing')",
|
||||||
|
"execute:webnotes.delete_doc('DocType', 'Warehouse Type')",
|
||||||
]
|
]
|
||||||
@ -158,6 +158,10 @@ def set_defaults(args):
|
|||||||
hr_settings.doc.emp_created_by = "Naming Series"
|
hr_settings.doc.emp_created_by = "Naming Series"
|
||||||
hr_settings.save()
|
hr_settings.save()
|
||||||
|
|
||||||
|
email_settings = webnotes.bean("Email Settings")
|
||||||
|
email_settings.doc.send_print_in_body_and_attachment = 1
|
||||||
|
email_settings.save()
|
||||||
|
|
||||||
# control panel
|
# control panel
|
||||||
cp = webnotes.doc("Control Panel", "Control Panel")
|
cp = webnotes.doc("Control Panel", "Control Panel")
|
||||||
cp.company_name = args["company_name"]
|
cp.company_name = args["company_name"]
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user