From 2880a55a01025bc89172dd1d1a44c9dd41abd169 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Thu, 20 Dec 2012 16:00:27 +0530 Subject: [PATCH] production order naming series patch --- .../production_order/production_order.py | 5 --- .../production_order/production_order.txt | 42 +++++++++---------- .../production_order_naming_series.py | 15 +++++++ patches/patch_list.py | 4 ++ 4 files changed, 39 insertions(+), 27 deletions(-) create mode 100644 patches/december_2012/production_order_naming_series.py diff --git a/manufacturing/doctype/production_order/production_order.py b/manufacturing/doctype/production_order/production_order.py index 0b9a94a6fb..3ba368efca 100644 --- a/manufacturing/doctype/production_order/production_order.py +++ b/manufacturing/doctype/production_order/production_order.py @@ -33,11 +33,6 @@ class DocType: self.doc = doc self.doclist = doclist - - def autoname(self): - self.doc.name = make_autoname('PRO/' + self.doc.fiscal_year[2:5] + - self.doc.fiscal_year[7:9] + '/.######') - def validate(self): if self.doc.production_item : item_detail = sql("select name from `tabItem` where name = '%s' and docstatus != 2" diff --git a/manufacturing/doctype/production_order/production_order.txt b/manufacturing/doctype/production_order/production_order.txt index 0de80f33bf..0f94d4e83a 100644 --- a/manufacturing/doctype/production_order/production_order.txt +++ b/manufacturing/doctype/production_order/production_order.txt @@ -2,12 +2,13 @@ { "owner": "Administrator", "docstatus": 0, - "creation": "2012-12-19 22:39:06", + "creation": "2012-12-20 14:31:18", "modified_by": "Administrator", - "modified": "2012-12-20 13:57:10" + "modified": "2012-12-20 15:50:43" }, { "is_submittable": 1, + "autoname": "naming_series:", "in_create": 0, "doctype": "DocType", "module": "Manufacturing", @@ -22,18 +23,33 @@ "parentfield": "fields" }, { - "name": "__common__", "parent": "Production Order", "read": 1, + "cancel": 1, + "name": "__common__", + "amend": 1, + "create": 1, "doctype": "DocPerm", + "submit": 1, + "write": 1, "parenttype": "DocType", "role": "Manufacturing User", + "permlevel": 0, "parentfield": "permissions" }, { "name": "Production Order", "doctype": "DocType" }, + { + "default": "PRO", + "doctype": "DocField", + "label": "Series", + "fieldname": "naming_series", + "fieldtype": "Select", + "reqd": 1, + "options": "\nPRO" + }, { "read_only": 1, "depends_on": "eval:!doc.__islocal", @@ -171,14 +187,6 @@ "reqd": 1, "options": "Company" }, - { - "doctype": "DocField", - "label": "Fiscal Year", - "fieldname": "fiscal_year", - "fieldtype": "Select", - "reqd": 1, - "options": "link:Fiscal Year" - }, { "read_only": 1, "no_copy": 1, @@ -190,16 +198,6 @@ "fieldtype": "Data" }, { - "amend": 1, - "create": 1, - "doctype": "DocPerm", - "submit": 1, - "write": 1, - "cancel": 1, - "permlevel": 0 - }, - { - "doctype": "DocPerm", - "permlevel": 1 + "doctype": "DocPerm" } ] \ No newline at end of file diff --git a/patches/december_2012/production_order_naming_series.py b/patches/december_2012/production_order_naming_series.py new file mode 100644 index 0000000000..df011cb731 --- /dev/null +++ b/patches/december_2012/production_order_naming_series.py @@ -0,0 +1,15 @@ +import webnotes + +def execute(): + from webnotes.utils import cstr + from webnotes.model.code import get_obj + + fy_list = webnotes.conn.sql("""select name from `tabFiscal Year` + where docstatus < 2 order by year_start_date desc""") + series_list = [] + for fy in fy_list: + series_list.append("PRO/" + cstr(fy[0][2:5]) + cstr(fy[0][7:9]) + "/") + + naming_series_obj = get_obj("Naming Series") + naming_series_obj.doc.user_must_always_select = 1 + naming_series_obj.set_series_for("Production Order", series_list) \ No newline at end of file diff --git a/patches/patch_list.py b/patches/patch_list.py index b97e47b8cb..86bb18857f 100644 --- a/patches/patch_list.py +++ b/patches/patch_list.py @@ -550,4 +550,8 @@ patch_list = [ 'patch_module': 'patches.december_2012', 'patch_file': 'stock_entry_cleanup', }, + { + 'patch_module': 'patches.december_2012', + 'patch_file': 'production_order_naming_series', + }, ] \ No newline at end of file