From 5717fe3abade77b7390240717dfa288525615017 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Wed, 17 Apr 2013 18:02:52 +0530 Subject: [PATCH] [cost center] [default value] default cost center for each company, auto set default cost center for various transactions during creation --- .../journal_voucher_detail.txt | 3 ++- .../purchase_invoice_item/purchase_invoice_item.txt | 5 +++-- .../purchase_taxes_and_charges.txt | 5 +++-- .../sales_invoice_item/sales_invoice_item.txt | 5 +++-- .../sales_taxes_and_charges.txt | 3 ++- setup/doctype/company/company.py | 3 +++ setup/doctype/company/company.txt | 13 +++++++++++-- startup/boot.py | 3 ++- .../delivery_note_item/delivery_note_item.txt | 5 +++-- 9 files changed, 32 insertions(+), 13 deletions(-) diff --git a/accounts/doctype/journal_voucher_detail/journal_voucher_detail.txt b/accounts/doctype/journal_voucher_detail/journal_voucher_detail.txt index ac30346d2c..68019cb840 100644 --- a/accounts/doctype/journal_voucher_detail/journal_voucher_detail.txt +++ b/accounts/doctype/journal_voucher_detail/journal_voucher_detail.txt @@ -2,7 +2,7 @@ { "creation": "2013-02-22 01:27:39", "docstatus": 0, - "modified": "2013-03-07 07:03:23", + "modified": "2013-04-17 14:05:18", "modified_by": "Administrator", "owner": "Administrator" }, @@ -58,6 +58,7 @@ "options": "Company:company:default_currency" }, { + "default": ":Company", "doctype": "DocField", "fieldname": "cost_center", "fieldtype": "Link", diff --git a/accounts/doctype/purchase_invoice_item/purchase_invoice_item.txt b/accounts/doctype/purchase_invoice_item/purchase_invoice_item.txt index 5e9daf758d..e33ab7c569 100755 --- a/accounts/doctype/purchase_invoice_item/purchase_invoice_item.txt +++ b/accounts/doctype/purchase_invoice_item/purchase_invoice_item.txt @@ -1,8 +1,8 @@ [ { - "creation": "2013-03-07 11:42:55", + "creation": "2013-04-10 08:35:38", "docstatus": 0, - "modified": "2013-03-29 13:44:37", + "modified": "2013-04-17 14:05:20", "modified_by": "Administrator", "owner": "Administrator" }, @@ -170,6 +170,7 @@ "width": "120px" }, { + "default": ":Company", "doctype": "DocField", "fieldname": "cost_center", "fieldtype": "Link", diff --git a/accounts/doctype/purchase_taxes_and_charges/purchase_taxes_and_charges.txt b/accounts/doctype/purchase_taxes_and_charges/purchase_taxes_and_charges.txt index b593b8175b..576730779a 100644 --- a/accounts/doctype/purchase_taxes_and_charges/purchase_taxes_and_charges.txt +++ b/accounts/doctype/purchase_taxes_and_charges/purchase_taxes_and_charges.txt @@ -1,8 +1,8 @@ [ { - "creation": "2013-03-08 15:36:47", + "creation": "2013-03-26 06:51:12", "docstatus": 0, - "modified": "2013-03-22 16:45:28", + "modified": "2013-04-17 14:05:19", "modified_by": "Administrator", "owner": "Administrator" }, @@ -58,6 +58,7 @@ "reqd": 1 }, { + "default": ":Company", "doctype": "DocField", "fieldname": "cost_center", "fieldtype": "Link", diff --git a/accounts/doctype/sales_invoice_item/sales_invoice_item.txt b/accounts/doctype/sales_invoice_item/sales_invoice_item.txt index 98962b5bbc..2a6384d762 100644 --- a/accounts/doctype/sales_invoice_item/sales_invoice_item.txt +++ b/accounts/doctype/sales_invoice_item/sales_invoice_item.txt @@ -1,8 +1,8 @@ [ { - "creation": "2013-03-29 18:21:58", + "creation": "2013-04-10 08:35:44", "docstatus": 0, - "modified": "2013-03-29 19:32:32", + "modified": "2013-04-17 14:05:20", "modified_by": "Administrator", "owner": "Administrator" }, @@ -219,6 +219,7 @@ "width": "120px" }, { + "default": ":Company", "doctype": "DocField", "fieldname": "cost_center", "fieldtype": "Link", diff --git a/accounts/doctype/sales_taxes_and_charges/sales_taxes_and_charges.txt b/accounts/doctype/sales_taxes_and_charges/sales_taxes_and_charges.txt index 3b3252426b..161eb008ea 100644 --- a/accounts/doctype/sales_taxes_and_charges/sales_taxes_and_charges.txt +++ b/accounts/doctype/sales_taxes_and_charges/sales_taxes_and_charges.txt @@ -2,7 +2,7 @@ { "creation": "2013-02-22 01:27:41", "docstatus": 0, - "modified": "2013-03-07 07:03:31", + "modified": "2013-04-17 14:05:18", "modified_by": "Administrator", "owner": "Administrator" }, @@ -48,6 +48,7 @@ "search_index": 1 }, { + "default": ":Company", "doctype": "DocField", "fieldname": "cost_center_other_charges", "fieldtype": "Link", diff --git a/setup/doctype/company/company.py b/setup/doctype/company/company.py index 964b886ed7..78be5380b2 100644 --- a/setup/doctype/company/company.py +++ b/setup/doctype/company/company.py @@ -245,6 +245,9 @@ class DocType: for cc in cc_list: add_cc(cc) + webnotes.conn.set_value("Company", self.doc.name, "cost_center", + "Default CC Ledger - " + self.doc.abbr) + def on_update(self): self.set_letter_head() diff --git a/setup/doctype/company/company.txt b/setup/doctype/company/company.txt index a49a7e0fe7..c4176d8132 100644 --- a/setup/doctype/company/company.txt +++ b/setup/doctype/company/company.txt @@ -1,8 +1,8 @@ [ { - "creation": "2013-03-26 11:03:08", + "creation": "2013-04-10 08:35:39", "docstatus": 0, - "modified": "2013-03-28 16:04:27", + "modified": "2013-04-17 14:07:46", "modified_by": "Administrator", "owner": "Administrator" }, @@ -141,6 +141,15 @@ "options": "Account", "read_only": 0 }, + { + "depends_on": "eval:!doc.__islocal", + "doctype": "DocField", + "fieldname": "cost_center", + "fieldtype": "Link", + "label": "Cost Center", + "no_copy": 1, + "options": "Cost Center" + }, { "doctype": "DocField", "fieldname": "column_break0", diff --git a/startup/boot.py b/startup/boot.py index 4774a903aa..9ed20ff73a 100644 --- a/startup/boot.py +++ b/startup/boot.py @@ -36,7 +36,8 @@ def boot_session(bootinfo): for key in ['max_users', 'expires_on', 'max_space', 'status', 'developer_mode']: if hasattr(conf, key): bootinfo[key] = getattr(conf, key) - bootinfo['docs'] += webnotes.conn.sql("select name, default_currency from `tabCompany`", + bootinfo['docs'] += webnotes.conn.sql("""select name, default_currency, cost_center, + cost_center as 'cost_center_other_charges' from `tabCompany`""", as_dict=1, update={"doctype":":Company"}) def get_letter_heads(): diff --git a/stock/doctype/delivery_note_item/delivery_note_item.txt b/stock/doctype/delivery_note_item/delivery_note_item.txt index fb3dd413ef..379ee6a00d 100644 --- a/stock/doctype/delivery_note_item/delivery_note_item.txt +++ b/stock/doctype/delivery_note_item/delivery_note_item.txt @@ -1,8 +1,8 @@ [ { - "creation": "2013-03-26 11:03:09", + "creation": "2013-04-01 10:49:21", "docstatus": 0, - "modified": "2013-03-28 15:42:41", + "modified": "2013-04-17 14:05:19", "modified_by": "Administrator", "owner": "Administrator" }, @@ -257,6 +257,7 @@ "width": "120px" }, { + "default": ":Company", "doctype": "DocField", "fieldname": "cost_center", "fieldtype": "Link",