Merge pull request #2108 from neilLasrado/fix-issue-448

[Fix] Issue #448
This commit is contained in:
Anand Doshi 2014-08-29 15:46:13 +05:30
commit 98ff85dea1
9 changed files with 78 additions and 47 deletions

View File

@ -144,8 +144,8 @@
],
"icon": "icon-money",
"idx": 1,
"in_create": 1,
"modified": "2014-05-27 03:49:08.910126",
"in_create": 0,
"modified": "2014-08-26 12:16:11.163750",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Cost Center",

View File

@ -227,6 +227,17 @@
"fieldtype": "Column Break",
"permlevel": 0
},
{
"fieldname": "project_name",
"fieldtype": "Link",
"in_filter": 1,
"in_list_view": 0,
"label": "Project Name",
"options": "Project",
"permlevel": 0,
"print_hide": 1,
"read_only": 0
},
{
"default": ":Company",
"fieldname": "cost_center",
@ -249,17 +260,6 @@
"label": "Reference",
"permlevel": 0
},
{
"fieldname": "project_name",
"fieldtype": "Link",
"in_filter": 1,
"in_list_view": 0,
"label": "Project Name",
"options": "Project",
"permlevel": 0,
"print_hide": 1,
"read_only": 0
},
{
"fieldname": "brand",
"fieldtype": "Data",
@ -317,23 +317,6 @@
"search_index": 0,
"width": "150px"
},
{
"allow_on_submit": 1,
"fieldname": "page_break",
"fieldtype": "Check",
"in_list_view": 0,
"label": "Page Break",
"no_copy": 1,
"permlevel": 0,
"print_hide": 1,
"read_only": 0,
"report_hide": 1
},
{
"fieldname": "col_break6",
"fieldtype": "Column Break",
"permlevel": 0
},
{
"fieldname": "purchase_order",
"fieldtype": "Link",
@ -349,6 +332,11 @@
"read_only": 1,
"search_index": 1
},
{
"fieldname": "col_break6",
"fieldtype": "Column Break",
"permlevel": 0
},
{
"fieldname": "po_detail",
"fieldtype": "Data",
@ -379,6 +367,18 @@
"read_only": 1,
"search_index": 1
},
{
"allow_on_submit": 1,
"fieldname": "page_break",
"fieldtype": "Check",
"in_list_view": 0,
"label": "Page Break",
"no_copy": 1,
"permlevel": 0,
"print_hide": 1,
"read_only": 0,
"report_hide": 1
},
{
"fieldname": "pr_detail",
"fieldtype": "Data",
@ -421,7 +421,7 @@
],
"idx": 1,
"istable": 1,
"modified": "2014-07-24 05:50:20.570629",
"modified": "2014-08-26 12:34:42.790959",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Purchase Invoice Item",

View File

@ -385,6 +385,6 @@ erpnext.buying.BuyingController = erpnext.TransactionController.extend({
});
}
});
cur_frm.add_fetch('project_name', 'cost_center', 'cost_center');
var tname = cur_frm.cscript.tname;
var fname = cur_frm.cscript.fname;

View File

@ -1,5 +1,6 @@
{
"allow_import": 1,
"allow_attach": 1,
"allow_import": 1,
"allow_rename": 1,
"autoname": "field:project_name",
"creation": "2013-03-07 11:55:07",
@ -207,6 +208,13 @@
"permlevel": 0,
"search_index": 0
},
{
"fieldname": "cost_center",
"fieldtype": "Link",
"label": "Default Cost Center",
"options": "Cost Center",
"permlevel": 0
},
{
"fieldname": "column_break0",
"fieldtype": "Column Break",
@ -265,7 +273,7 @@
"icon": "icon-puzzle-piece",
"idx": 1,
"max_attachments": 4,
"modified": "2014-08-04 03:22:11.416219",
"modified": "2014-08-26 14:59:27.052172",
"modified_by": "Administrator",
"module": "Projects",
"name": "Project",

View File

@ -67,3 +67,7 @@ class Project(Document):
def on_trash(self):
delete_events(self.doctype, self.name)
@frappe.whitelist()
def get_cost_center_name(project_name):
return frappe.db.get_value("Project", project_name, "cost_center")

View File

@ -151,9 +151,11 @@ erpnext.TransactionController = erpnext.stock.StockController.extend({
transaction_date: me.frm.doc.transaction_date,
ignore_pricing_rule: me.frm.doc.ignore_pricing_rule,
doctype: item.doctype,
name: item.name
name: item.name,
project_name: item.project_name || me.frm.doc.project_name
}
},
callback: function(r) {
if(!r.exc) {
me.frm.script_manager.trigger("price_list_rate", cdt, cdn);

View File

@ -585,3 +585,18 @@ erpnext.selling.SellingController = erpnext.TransactionController.extend({
});
}
});
frappe.ui.form.on(cur_frm.doctype,"project_name", function(frm) {
frappe.call({
method:'erpnext.projects.doctype.project.project.get_cost_center_name' ,
args: { project_name: frm.doc.project_name },
callback: function(r, rt) {
if(!r.exc) {
$.each(frm.doc[cur_frm.cscript.fname] || [], function(i, row) {
frappe.model.set_value(row.doctype, row.name, "cost_center", r.message);
msgprint(__("Cost Center For Item with Item Code '"+row.item_name+"' has been Changed to "+ r.message));
})
}
}
})
})

View File

@ -300,16 +300,6 @@
"read_only": 0,
"width": "100px"
},
{
"default": ":Company",
"depends_on": "eval:cint(sys_defaults.auto_accounting_for_stock)",
"fieldname": "cost_center",
"fieldtype": "Link",
"label": "Cost Center",
"options": "Cost Center",
"permlevel": 0,
"print_hide": 1
},
{
"fieldname": "project_name",
"fieldtype": "Link",
@ -320,6 +310,16 @@
"print_hide": 1,
"read_only": 0
},
{
"default": ":Company",
"depends_on": "eval:cint(sys_defaults.auto_accounting_for_stock)",
"fieldname": "cost_center",
"fieldtype": "Link",
"label": "Cost Center",
"options": "Cost Center",
"permlevel": 0,
"print_hide": 1
},
{
"fieldname": "qa_no",
"fieldtype": "Link",
@ -557,7 +557,7 @@
],
"idx": 1,
"istable": 1,
"modified": "2014-08-11 12:48:13.509109",
"modified": "2014-08-26 12:38:04.065982",
"modified_by": "Administrator",
"module": "Stock",
"name": "Purchase Receipt Item",

View File

@ -29,6 +29,7 @@ def get_item_details(args):
"is_subcontracted": "Yes" / "No",
"transaction_type": "selling",
"ignore_pricing_rule": 0/1
"project_name": "",
}
"""
args = process_args(args)
@ -149,7 +150,8 @@ def get_basic_details(args, item_doc):
or args.expense_account
or frappe.db.get_value("Item Group", item.item_group, "default_expense_account")
or frappe.db.get_value("Company", args.company, "default_expense_account")),
"cost_center": ((item.selling_cost_center if args.transaction_type == "selling" else item.buying_cost_center)
"cost_center": (frappe.db.get_value("Project", args.project_name, "cost_center")
or (item.selling_cost_center if args.transaction_type == "selling" else item.buying_cost_center)
or frappe.db.get_value("Item Group", item.item_group, "default_cost_center")
or frappe.db.get_value("Company", args.company, "cost_center")),
"batch_no": None,