From 7a0daeb01a6485d8d6df50c9b536f8c9de3c5b57 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Fri, 30 Aug 2013 15:58:47 +0530 Subject: [PATCH 1/3] [patch] [minor] to fix fiscal_years based on start date - only for single account --- patches/august_2013/fix_fiscal_year.py | 49 ++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 patches/august_2013/fix_fiscal_year.py diff --git a/patches/august_2013/fix_fiscal_year.py b/patches/august_2013/fix_fiscal_year.py new file mode 100644 index 0000000000..49c1975a0b --- /dev/null +++ b/patches/august_2013/fix_fiscal_year.py @@ -0,0 +1,49 @@ +import webnotes + +def execute(): + # create_fiscal_years() + + doctypes = webnotes.conn.sql_list("""select parent from tabDocField + where (fieldtype="Link" and options='Fiscal Year') + or (fieldtype="Select" and options='link:Fiscal Year')""") + + for dt in doctypes: + date_fields = webnotes.conn.sql_list("""select fieldname from tabDocField + where parent=%s and fieldtype='Date'""", dt) + + date_field = get_date_field(date_fields, dt) + + if not date_field: + print dt, date_field + else: + webnotes.conn.sql("""update `tab%s` set fiscal_year = + if(%s<='2013-06-30', '2012-2013', '2013-2014')""" % (dt, date_field)) + +def create_fiscal_years(): + fiscal_years = { + "2012-2013": ["2012-07-01", "2013-06-30"], + "2013-2014": ["2013-07-01", "2014-06-30"] + } + + for d in fiscal_years: + webnotes.bean({ + "doctype": "Fiscal Year", + "year": d, + "year_start_date": fiscal_years[d][0], + "is_fiscal_year_closed": "No" + }).insert() + + +def get_date_field(date_fields, dt): + date_field = None + if date_fields: + if "posting_date" in date_fields: + date_field = "posting_date" + elif "transaction_date" in date_fields: + date_field = 'transaction_date' + else: + date_field = date_fields[0] + # print dt, date_fields + + return date_field + \ No newline at end of file From d56da20fad10c10e5b7f9f3c6e407eca42a9c38e Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Fri, 30 Aug 2013 16:02:22 +0530 Subject: [PATCH 2/3] [patch] [minor] to fix fiscal_years based on start date - only for single account --- patches/august_2013/fix_fiscal_year.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/patches/august_2013/fix_fiscal_year.py b/patches/august_2013/fix_fiscal_year.py index 49c1975a0b..67988c440e 100644 --- a/patches/august_2013/fix_fiscal_year.py +++ b/patches/august_2013/fix_fiscal_year.py @@ -1,7 +1,7 @@ import webnotes def execute(): - # create_fiscal_years() + create_fiscal_years() doctypes = webnotes.conn.sql_list("""select parent from tabDocField where (fieldtype="Link" and options='Fiscal Year') From da1e503f3ddee84c2a928fa48909fec166f1de34 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Fri, 30 Aug 2013 16:24:44 +0530 Subject: [PATCH 3/3] [fix] [minor] removed sample item field from item --- .../doctype/sales_invoice/sales_invoice.py | 4 +- stock/doctype/item/item.txt | 38 ++----------------- stock/doctype/item/test_item.py | 8 ---- 3 files changed, 5 insertions(+), 45 deletions(-) diff --git a/accounts/doctype/sales_invoice/sales_invoice.py b/accounts/doctype/sales_invoice/sales_invoice.py index f4ac6b08c0..17ae216e02 100644 --- a/accounts/doctype/sales_invoice/sales_invoice.py +++ b/accounts/doctype/sales_invoice/sales_invoice.py @@ -549,9 +549,7 @@ class DocType(SellingController): self.values = [] items = get_obj('Sales Common').get_item_list(self) for d in items: - stock_item = webnotes.conn.sql("SELECT is_stock_item, is_sample_item \ - FROM tabItem where name = '%s'"%(d['item_code']), as_dict = 1) - if stock_item[0]['is_stock_item'] == "Yes": + if webnotes.conn.get_value("Item", d['item_code'], "is_stock_item") == "Yes": if not d['warehouse']: msgprint("Message: Please enter Warehouse for item %s as it is stock item." \ % d['item_code'], raise_exception=1) diff --git a/stock/doctype/item/item.txt b/stock/doctype/item/item.txt index 8b17aee6bb..eb05503b32 100644 --- a/stock/doctype/item/item.txt +++ b/stock/doctype/item/item.txt @@ -2,7 +2,7 @@ { "creation": "2013-05-03 10:45:46", "docstatus": 0, - "modified": "2013-08-14 11:46:49", + "modified": "2013-08-30 16:21:38", "modified_by": "Administrator", "owner": "Administrator" }, @@ -35,7 +35,9 @@ "parentfield": "permissions", "parenttype": "DocType", "permlevel": 0, - "read": 1 + "read": 1, + "report": 1, + "submit": 0 }, { "doctype": "DocType", @@ -557,20 +559,6 @@ "read_only": 0, "reqd": 1 }, - { - "default": "No", - "depends_on": "eval:doc.is_sales_item==\"Yes\"", - "description": "Select \"Yes\" if this item is to be sent to a customer or received from a supplier as a sample. Delivery notes and Purchase Receipts will update stock levels but there will be no invoice against this item.", - "doctype": "DocField", - "fieldname": "is_sample_item", - "fieldtype": "Select", - "label": "Allow Samples", - "oldfieldname": "is_sample_item", - "oldfieldtype": "Select", - "options": "Yes\nNo", - "read_only": 0, - "reqd": 1 - }, { "depends_on": "eval:doc.is_sales_item==\"Yes\"", "doctype": "DocField", @@ -878,9 +866,7 @@ "cancel": 1, "create": 1, "doctype": "DocPerm", - "report": 1, "role": "Material Master Manager", - "submit": 0, "write": 1 }, { @@ -888,9 +874,7 @@ "cancel": 0, "create": 0, "doctype": "DocPerm", - "report": 1, "role": "Material Manager", - "submit": 0, "write": 0 }, { @@ -898,21 +882,7 @@ "cancel": 0, "create": 0, "doctype": "DocPerm", - "report": 1, "role": "Material User", - "submit": 0, "write": 0 - }, - { - "doctype": "DocPerm", - "role": "Sales User" - }, - { - "doctype": "DocPerm", - "role": "Purchase User" - }, - { - "doctype": "DocPerm", - "role": "Accounts User" } ] \ No newline at end of file diff --git a/stock/doctype/item/test_item.py b/stock/doctype/item/test_item.py index b9b67e2db1..7be6ea56ed 100644 --- a/stock/doctype/item/test_item.py +++ b/stock/doctype/item/test_item.py @@ -44,7 +44,6 @@ test_records = [ "is_purchase_item": "Yes", "is_sales_item": "Yes", "is_service_item": "No", - "is_sample_item": "No", "inspection_required": "No", "is_pro_applicable": "No", "is_sub_contracted_item": "No", @@ -82,7 +81,6 @@ test_records = [ "is_purchase_item": "Yes", "is_sales_item": "Yes", "is_service_item": "No", - "is_sample_item": "No", "inspection_required": "No", "is_pro_applicable": "No", "is_sub_contracted_item": "No", @@ -108,7 +106,6 @@ test_records = [ "is_purchase_item": "Yes", "is_sales_item": "Yes", "is_service_item": "No", - "is_sample_item": "No", "inspection_required": "No", "is_pro_applicable": "No", "is_sub_contracted_item": "No", @@ -128,7 +125,6 @@ test_records = [ "is_purchase_item": "Yes", "is_sales_item": "Yes", "is_service_item": "No", - "is_sample_item": "No", "inspection_required": "No", "is_pro_applicable": "No", "is_sub_contracted_item": "No", @@ -149,7 +145,6 @@ test_records = [ "is_purchase_item": "Yes", "is_sales_item": "Yes", "is_service_item": "No", - "is_sample_item": "No", "inspection_required": "No", "is_pro_applicable": "Yes", "is_sub_contracted_item": "Yes", @@ -168,7 +163,6 @@ test_records = [ "is_purchase_item": "Yes", "is_sales_item": "Yes", "is_service_item": "No", - "is_sample_item": "No", "inspection_required": "No", "is_pro_applicable": "No", "is_sub_contracted_item": "No", @@ -188,7 +182,6 @@ test_records = [ "is_purchase_item": "Yes", "is_sales_item": "Yes", "is_service_item": "No", - "is_sample_item": "No", "inspection_required": "No", "is_pro_applicable": "No", "is_sub_contracted_item": "No", @@ -209,7 +202,6 @@ test_records = [ "is_purchase_item": "Yes", "is_sales_item": "Yes", "is_service_item": "No", - "is_sample_item": "No", "inspection_required": "No", "is_pro_applicable": "No", "is_sub_contracted_item": "No",