Fixes in Production Planning Tool

This commit is contained in:
Neil Trini Lasrado 2015-07-08 18:16:51 +05:30
parent dcef448f1e
commit fe2ffaeafa
9 changed files with 30 additions and 25 deletions

View File

@ -369,15 +369,15 @@ cur_frm.fields_dict["items"].grid.get_field("cost_center").get_query = function(
}
cur_frm.cscript.income_account = function(doc, cdt, cdn) {
cur_frm.cscript.copy_account_in_all_row(doc, cdt, cdn, "income_account");
erpnext.utils.copy_value_in_all_row(doc, cdt, cdn, "items", "income_account");
}
cur_frm.cscript.expense_account = function(doc, cdt, cdn) {
cur_frm.cscript.copy_account_in_all_row(doc, cdt, cdn, "expense_account");
erpnext.utils.copy_value_in_all_row(doc, cdt, cdn, "items", "expense_account");
}
cur_frm.cscript.cost_center = function(doc, cdt, cdn) {
cur_frm.cscript.copy_account_in_all_row(doc, cdt, cdn, "cost_center");
erpnext.utils.copy_value_in_all_row(doc, cdt, cdn, "items", "cost_center");
}
cur_frm.cscript.on_submit = function(doc, cdt, cdn) {

View File

@ -83,9 +83,8 @@ def set_contact_details(out, party, party_type):
"contact_designation": None,
"contact_department": None
})
return
out.update(get_contact_details(out.contact_person))
else:
out.update(get_contact_details(out.contact_person))
def set_other_values(out, party, party_type):
# copy

View File

@ -249,7 +249,7 @@ cur_frm.cscript.on_submit = function(doc, cdt, cdn) {
cur_frm.cscript.schedule_date = function(doc, cdt, cdn) {
cur_frm.cscript.copy_account_in_all_row(doc, cdt, cdn, "schedule_date");
erpnext.utils.copy_value_in_all_row(doc, cdt, cdn, "items", "schedule_date");
}
frappe.provide("erpnext.buying");

View File

@ -43,12 +43,13 @@
"width": "100px"
},
{
"default": "now",
"default": "",
"fieldname": "planned_start_date",
"fieldtype": "Datetime",
"label": "Planned Start Date",
"permlevel": 0,
"precision": ""
"precision": "",
"reqd": 1
},
{
"fieldname": "sales_order",
@ -112,7 +113,7 @@
],
"idx": 1,
"istable": 1,
"modified": "2015-07-07 07:52:40.883761",
"modified": "2015-07-08 07:12:11.211808",
"modified_by": "Administrator",
"module": "Manufacturing",
"name": "Production Plan Item",

View File

@ -1,6 +1,8 @@
// Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
// License: GNU General Public License v3. See license.txt
frappe.require("assets/erpnext/js/utils.js");
cur_frm.cscript.onload = function(doc, cdt, cdn) {
cur_frm.set_value("company", frappe.defaults.get_user_default("company"))
cur_frm.set_value("use_multi_level_bom", 1)
@ -72,3 +74,7 @@ cur_frm.fields_dict.customer.get_query = function(doc,cdt,cdn) {
cur_frm.fields_dict.sales_orders.grid.get_field("customer").get_query =
cur_frm.fields_dict.customer.get_query;
cur_frm.cscript.planned_start_date = function(doc, cdt, cdn) {
erpnext.utils.copy_value_in_all_row(doc, cdt, cdn, "items", "planned_start_date");
}

View File

@ -3,7 +3,7 @@
from __future__ import unicode_literals
import frappe
from frappe.utils import cstr, flt, cint, nowdate, now, add_days, comma_and
from frappe.utils import cstr, flt, cint, nowdate, add_days, comma_and
from frappe import msgprint, _
@ -153,7 +153,6 @@ class ProductionPlanningTool(Document):
pi.bom_no = item_details and item_details[0][2] or ''
pi.so_pending_qty = flt(p['pending_qty'])
pi.planned_qty = flt(p['pending_qty'])
pi.planned_start_date = now()
def validate_data(self):
self.validate_company()

View File

@ -70,16 +70,5 @@ erpnext.stock.StockController = frappe.ui.form.Controller.extend({
frappe.set_route("query-report", "General Ledger");
}, "icon-table");
}
},
copy_account_in_all_row: function(doc, dt, dn, fieldname) {
var d = locals[dt][dn];
if(d[fieldname]){
var cl = doc["items"] || [];
for(var i = 0; i < cl.length; i++) {
if(!cl[i][fieldname]) cl[i][fieldname] = d[fieldname];
}
}
refresh_field("items");
}
});

View File

@ -131,6 +131,17 @@ $.extend(erpnext.utils, {
}
);
}
},
copy_value_in_all_row: function(doc, dt, dn, table_fieldname, fieldname) {
var d = locals[dt][dn];
if(d[fieldname]){
var cl = doc[table_fieldname] || [];
for(var i = 0; i < cl.length; i++) {
if(!cl[i][fieldname]) cl[i][fieldname] = d[fieldname];
}
}
refresh_field(table_fieldname);
}
});

View File

@ -519,11 +519,11 @@ cur_frm.cscript.validate_items = function(doc) {
}
cur_frm.cscript.expense_account = function(doc, cdt, cdn) {
cur_frm.cscript.copy_account_in_all_row(doc, cdt, cdn, "expense_account");
erpnext.utils.copy_value_in_all_row(doc, cdt, cdn, "expense_account");
}
cur_frm.cscript.cost_center = function(doc, cdt, cdn) {
cur_frm.cscript.copy_account_in_all_row(doc, cdt, cdn, "cost_center");
erpnext.utils.copy_value_in_all_row(doc, cdt, cdn, "cost_center");
}
cur_frm.fields_dict.customer.get_query = function(doc, cdt, cdn) {