diff --git a/erpnext/accounts/doctype/cost_center/cost_center.json b/erpnext/accounts/doctype/cost_center/cost_center.json index 36cb6ae7e9..e65f74bdb9 100644 --- a/erpnext/accounts/doctype/cost_center/cost_center.json +++ b/erpnext/accounts/doctype/cost_center/cost_center.json @@ -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", diff --git a/erpnext/accounts/doctype/purchase_invoice_item/purchase_invoice_item.json b/erpnext/accounts/doctype/purchase_invoice_item/purchase_invoice_item.json index 22757430bf..d26dec0a92 100755 --- a/erpnext/accounts/doctype/purchase_invoice_item/purchase_invoice_item.json +++ b/erpnext/accounts/doctype/purchase_invoice_item/purchase_invoice_item.json @@ -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", diff --git a/erpnext/buying/doctype/purchase_common/purchase_common.js b/erpnext/buying/doctype/purchase_common/purchase_common.js index 3c63508991..c2e76e2ab7 100644 --- a/erpnext/buying/doctype/purchase_common/purchase_common.js +++ b/erpnext/buying/doctype/purchase_common/purchase_common.js @@ -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; diff --git a/erpnext/projects/doctype/project/project.json b/erpnext/projects/doctype/project/project.json index c7c459c5bc..f7a5754fb0 100644 --- a/erpnext/projects/doctype/project/project.json +++ b/erpnext/projects/doctype/project/project.json @@ -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", diff --git a/erpnext/projects/doctype/project/project.py b/erpnext/projects/doctype/project/project.py index 547e12aebc..88e6e122fe 100644 --- a/erpnext/projects/doctype/project/project.py +++ b/erpnext/projects/doctype/project/project.py @@ -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") \ No newline at end of file diff --git a/erpnext/public/js/transaction.js b/erpnext/public/js/transaction.js index 801ea57d21..4c0b341d48 100644 --- a/erpnext/public/js/transaction.js +++ b/erpnext/public/js/transaction.js @@ -151,7 +151,8 @@ 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) { diff --git a/erpnext/selling/sales_common.js b/erpnext/selling/sales_common.js index 20f1028d9a..8bb05c694f 100644 --- a/erpnext/selling/sales_common.js +++ b/erpnext/selling/sales_common.js @@ -585,3 +585,21 @@ 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.exe) { + $.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)); + }) + } + } + }) +}) diff --git a/erpnext/stock/doctype/purchase_receipt_item/purchase_receipt_item.json b/erpnext/stock/doctype/purchase_receipt_item/purchase_receipt_item.json index 0222e58da5..69c27556ce 100755 --- a/erpnext/stock/doctype/purchase_receipt_item/purchase_receipt_item.json +++ b/erpnext/stock/doctype/purchase_receipt_item/purchase_receipt_item.json @@ -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", diff --git a/erpnext/stock/get_item_details.py b/erpnext/stock/get_item_details.py index efb793deea..fffb52e835 100644 --- a/erpnext/stock/get_item_details.py +++ b/erpnext/stock/get_item_details.py @@ -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,