From 20a109452aa123ae25e3584997e0b474f0e52717 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Tue, 20 Aug 2013 15:18:42 +0530 Subject: [PATCH 01/10] [buying] [manufacturing] Added new Reports and fixes for demo --- .../purchase_common/purchase_common.py | 3 +- buying/page/buying_home/buying_home.js | 5 ++ .../production_order/production_order.py | 6 ++ .../material_request/material_request.py | 3 +- stock/doctype/stock_entry/stock_entry.py | 36 +++++--- stock/page/stock_home/stock_home.js | 5 ++ stock/report/item_shortage_report/__init__.py | 0 .../item_shortage_report.txt | 22 +++++ .../report/items_to_be_requested/__init__.py | 0 .../items_to_be_requested.txt | 22 +++++ utilities/demo_docs/Item.csv | 87 +++++++++++-------- utilities/make_demo.py | 85 +++++++++++++----- 12 files changed, 198 insertions(+), 76 deletions(-) create mode 100644 stock/report/item_shortage_report/__init__.py create mode 100644 stock/report/item_shortage_report/item_shortage_report.txt create mode 100644 stock/report/items_to_be_requested/__init__.py create mode 100644 stock/report/items_to_be_requested/items_to_be_requested.txt diff --git a/buying/doctype/purchase_common/purchase_common.py b/buying/doctype/purchase_common/purchase_common.py index 65bccaad2bb..9b6dc6c9ab7 100644 --- a/buying/doctype/purchase_common/purchase_common.py +++ b/buying/doctype/purchase_common/purchase_common.py @@ -20,8 +20,7 @@ class DocType(BuyingController): def is_item_table_empty(self, obj): if not len(obj.doclist.get({"parentfield": obj.fname})): - msgprint(_("Hey there! You need to put at least one item in \ - the item table."), raise_exception=True) + msgprint(_("You need to put at least one item in the item table."), raise_exception=True) def get_supplier_details(self, name = ''): details = sql("select supplier_name,address from `tabSupplier` where name = '%s' and docstatus != 2" %(name), as_dict = 1) diff --git a/buying/page/buying_home/buying_home.js b/buying/page/buying_home/buying_home.js index 939ff795767..5db57f4f02b 100644 --- a/buying/page/buying_home/buying_home.js +++ b/buying/page/buying_home/buying_home.js @@ -110,6 +110,11 @@ wn.module_page["Buying"] = [ right: true, icon: "icon-list", items: [ + { + "label":wn._("Items To Be Requested"), + route: "query-report/Items To Be Requested", + doctype: "Item" + }, { "label":wn._("Requested Items To Be Ordered"), route: "query-report/Requested Items To Be Ordered", diff --git a/manufacturing/doctype/production_order/production_order.py b/manufacturing/doctype/production_order/production_order.py index f86a55d7ed0..6cdbc2f046a 100644 --- a/manufacturing/doctype/production_order/production_order.py +++ b/manufacturing/doctype/production_order/production_order.py @@ -143,6 +143,12 @@ def get_item_details(item): def make_stock_entry(production_order_id, purpose): production_order = webnotes.bean("Production Order", production_order_id) + # validate already existing + ste = webnotes.conn.get_value("Stock Entry", { + "production_order":production_order_id, + "purpose": purpose + }, "name") + stock_entry = webnotes.new_bean("Stock Entry") stock_entry.doc.purpose = purpose stock_entry.doc.production_order = production_order_id diff --git a/stock/doctype/material_request/material_request.py b/stock/doctype/material_request/material_request.py index 4952834bfc7..9cb0bc5dd8a 100644 --- a/stock/doctype/material_request/material_request.py +++ b/stock/doctype/material_request/material_request.py @@ -51,10 +51,9 @@ class DocType(BuyingController): msgprint("You can raise indent of maximum qty: %s for item: %s against sales order: %s\n Anyway, you can add more qty in new row for the same item." % (actual_so_qty - already_indented, item, so_no), raise_exception=1) def validate_schedule_date(self): - #:::::::: validate schedule date v/s indent date :::::::::::: for d in getlist(self.doclist, 'indent_details'): if d.schedule_date < self.doc.transaction_date: - msgprint("Expected Schedule Date cannot be before Material Request Date") + msgprint("Expected Date cannot be before Material Request Date") raise Exception # Validate diff --git a/stock/doctype/stock_entry/stock_entry.py b/stock/doctype/stock_entry/stock_entry.py index b050c8cdd15..014e93e3267 100644 --- a/stock/doctype/stock_entry/stock_entry.py +++ b/stock/doctype/stock_entry/stock_entry.py @@ -20,6 +20,7 @@ sql = webnotes.conn.sql class NotUpdateStockError(webnotes.ValidationError): pass class StockOverReturnError(webnotes.ValidationError): pass class IncorrectValuationRateError(webnotes.ValidationError): pass +class DuplicateEntryForProductionOrderError(webnotes.ValidationError): pass from controllers.stock_controller import StockController @@ -146,21 +147,32 @@ class DocType(StockController): return if self.doc.purpose == "Manufacture/Repack": - if not flt(self.doc.fg_completed_qty): - msgprint(_("Manufacturing Quantity") + _(" is mandatory"), raise_exception=1) - - if flt(pro_obj.doc.qty) < (flt(pro_obj.doc.produced_qty) - + flt(self.doc.fg_completed_qty)): - # do not allow manufacture of qty > production order qty - msgprint(_("For Item ") + pro_obj.doc.production_item - + _("Quantity already manufactured") - + " = %s." % flt(pro_obj.doc.produced_qty) - + _("Hence, maximum allowed Manufacturing Quantity") - + " = %s." % (flt(pro_obj.doc.qty) - flt(pro_obj.doc.produced_qty)), - raise_exception=1) + # check for double entry + self.check_duplicate_entry_for_production_order() elif self.doc.purpose != "Material Transfer": self.doc.production_order = None + + def check_duplicate_entry_for_production_order(self): + other_ste = [t[0] for t in webnotes.conn.get_values("Stock Entry", { + "production_order": self.doc.production_order, + "purpose": self.doc.purpose, + "docstatus": ["!=", 2] + }, "name")] + + if other_ste: + production_item, qty = webnotes.conn.get_value("Production Order", + self.doc.production_order, ["production_item", "qty"]) + args = other_ste + [production_item] + fg_qty_already_entered = webnotes.conn.sql("""select sum(actual_qty) + from `tabStock Entry Detail` + where parent in (%s) + and item_code = %s + and ifnull(s_warehouse,'')='' """ % (", ".join(["%s" * len(other_ste)]), "%s"), args)[0][0] + if fg_qty_already_entered >= qty: + webnotes.throw(_("Stock Entries already created for Production Order ") + + self.doc.production_order + ":" + ", ".join(other_ste), DuplicateEntryForProductionOrderError) + def set_total_amount(self): self.doc.total_amount = sum([flt(item.amount) for item in self.doclist.get({"parentfield": "mtn_details"})]) diff --git a/stock/page/stock_home/stock_home.js b/stock/page/stock_home/stock_home.js index 580c2dc973b..1cab7547aad 100644 --- a/stock/page/stock_home/stock_home.js +++ b/stock/page/stock_home/stock_home.js @@ -180,6 +180,11 @@ wn.module_page["Stock"] = [ route: "query-report/Purchase Order Items To Be Received", doctype: "Purchase Receipt" }, + { + "label":wn._("Item Shortage Report"), + route: "Report/Bin/Item Shortage Report", + doctype: "Purchase Receipt" + }, { "label":wn._("Serial No Service Contract Expiry"), route: "Report/Serial No/Serial No Service Contract Expiry", diff --git a/stock/report/item_shortage_report/__init__.py b/stock/report/item_shortage_report/__init__.py new file mode 100644 index 00000000000..e69de29bb2d diff --git a/stock/report/item_shortage_report/item_shortage_report.txt b/stock/report/item_shortage_report/item_shortage_report.txt new file mode 100644 index 00000000000..7d54ace93fa --- /dev/null +++ b/stock/report/item_shortage_report/item_shortage_report.txt @@ -0,0 +1,22 @@ +[ + { + "creation": "2013-08-20 13:43:30", + "docstatus": 0, + "modified": "2013-08-20 13:46:15", + "modified_by": "Administrator", + "owner": "Administrator" + }, + { + "doctype": "Report", + "is_standard": "Yes", + "json": "{\"filters\":[[\"Bin\",\"projected_qty\",\"<\",\"0\"]],\"columns\":[[\"warehouse\",\"Bin\"],[\"item_code\",\"Bin\"],[\"actual_qty\",\"Bin\"],[\"ordered_qty\",\"Bin\"],[\"planned_qty\",\"Bin\"],[\"reserved_qty\",\"Bin\"],[\"projected_qty\",\"Bin\"]],\"sort_by\":\"Bin.projected_qty\",\"sort_order\":\"asc\",\"sort_by_next\":\"\",\"sort_order_next\":\"desc\"}", + "name": "__common__", + "ref_doctype": "Bin", + "report_name": "Item Shortage Report", + "report_type": "Report Builder" + }, + { + "doctype": "Report", + "name": "Item Shortage Report" + } +] \ No newline at end of file diff --git a/stock/report/items_to_be_requested/__init__.py b/stock/report/items_to_be_requested/__init__.py new file mode 100644 index 00000000000..e69de29bb2d diff --git a/stock/report/items_to_be_requested/items_to_be_requested.txt b/stock/report/items_to_be_requested/items_to_be_requested.txt new file mode 100644 index 00000000000..c149c969409 --- /dev/null +++ b/stock/report/items_to_be_requested/items_to_be_requested.txt @@ -0,0 +1,22 @@ +[ + { + "creation": "2013-08-20 15:08:10", + "docstatus": 0, + "modified": "2013-08-20 15:10:43", + "modified_by": "Administrator", + "owner": "Administrator" + }, + { + "doctype": "Report", + "is_standard": "Yes", + "name": "__common__", + "query": "SELECT\n tabBin.item_code as \"Item:Link/Item:120\",\n tabBin.warehouse as \"Item:Link/Warehouse:120\",\n tabBin.actual_qty as \"Actual:Float:90\",\n tabBin.indented_qty as \"Requested:Float:90\",\n tabBin.reserved_qty as \"Reserved:Float:90\",\n tabBin.ordered_qty as \"Ordered:Float:90\",\n tabBin.projected_qty as \"Projected:Float:90\"\nFROM\n tabBin, tabItem\nWHERE\n tabBin.item_code = tabItem.name\n AND tabItem.is_purchase_item = \"Yes\"\n AND tabBin.projected_qty < 0\nORDER BY\n tabBin.projected_qty ASC", + "ref_doctype": "Item", + "report_name": "Items To Be Requested", + "report_type": "Query Report" + }, + { + "doctype": "Report", + "name": "Items To Be Requested" + } +] \ No newline at end of file diff --git a/utilities/demo_docs/Item.csv b/utilities/demo_docs/Item.csv index 3580748e1de..789e10cc790 100644 --- a/utilities/demo_docs/Item.csv +++ b/utilities/demo_docs/Item.csv @@ -1,37 +1,50 @@ -Data Import Template,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, -Table:,Item,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, -,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, -,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, -Notes:,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, -Please do not change the template headings.,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, -First data column must be blank.,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, -"If you are uploading new records, leave the ""name"" (ID) column blank.",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, -"If you are uploading new records, ""Naming Series"" becomes mandatory, if present.",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, -Only mandatory fields are necessary for new records. You can delete non-mandatory columns if you wish.,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, -"For updating, you can update only selective columns.",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, -You can only upload upto 5000 records in one go. (may be less in some cases),,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, -,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, -DocType:,Item,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, -Column Labels:,ID,Item Name,Item Group,Default Unit of Measure,Description,Is Stock Item,Is Asset Item,Has Batch No,Has Serial No,Is Purchase Item,Is Sales Item,Is Service Item,Allow Samples,Inspection Required,Allow Bill of Materials,Allow Production Order,Is Sub Contracted Item,Document Numbering Series,Item Code,Brand,Barcode,Image,Description HTML,Default Warehouse,Allowance Percent,Valuation Method,Minimum Order Qty,Warranty Period (in days),End of Life,Net Weight,Weight UOM,Re-Order Level,Re-Order Qty,Default Supplier,Lead Time Days,Default Expense Account,Default Cost Center,Last Purchase Rate,Standard Rate,Manufacturer,Manufacturer Part Number,Max Discount (%),Default Income Account,Cost Center,Default BOM,Show in Website,Page Name,Weightage,Slideshow,Image,Website Warehouse,Website Description -Column Name:,name,item_name,item_group,stock_uom,description,is_stock_item,is_asset_item,has_batch_no,has_serial_no,is_purchase_item,is_sales_item,is_service_item,is_sample_item,inspection_required,is_manufactured_item,is_pro_applicable,is_sub_contracted_item,naming_series,item_code,brand,barcode,image,description_html,default_warehouse,tolerance,valuation_method,min_order_qty,warranty_period,end_of_life,net_weight,weight_uom,re_order_level,re_order_qty,default_supplier,lead_time_days,purchase_account,cost_center,last_purchase_rate,standard_rate,manufacturer,manufacturer_part_no,max_discount,default_income_account,default_sales_cost_center,default_bom,show_in_website,page_name,weightage,slideshow,website_image,website_warehouse,web_long_description -Mandatory:,Yes,Yes,Yes,Yes,Yes,Yes,Yes,Yes,Yes,Yes,Yes,Yes,Yes,Yes,Yes,Yes,Yes,No,No,No,No,No,No,No,No,No,No,No,No,No,No,No,No,No,No,No,No,No,No,No,No,No,No,No,No,No,No,No,No,No,No,No -Type:,Data (text),Data,Link,Link,Small Text,Select,Select,Select,Select,Select,Select,Select,Select,Select,Select,Select,Select,Select,Data,Link,Data,Select,Small Text,Link,Float,Select,Float,Data,Date,Float,Link,Float,Float,Link,Int,Link,Link,Float,Float,Data,Data,Float,Link,Link,Link,Check,Data,Int,Link,Select,Link,Text Editor -Info:,,,Valid Item Group,Valid UOM,,"One of: Yes, No","One of: Yes, No","One of: Yes, No","One of: Yes, No","One of: Yes, No","One of: Yes, No","One of: Yes, No","One of: Yes, No","One of: Yes, No","One of: Yes, No","One of: Yes, No","One of: Yes, No",One of: ITEM,,Valid Brand,,One of: attach_files:,,Valid Warehouse,,"One of: FIFO, Moving Average",,,,,Valid UOM,,,Valid Supplier,Integer,Valid Account,Valid Cost Center,,,,,,Valid Account,Valid Cost Center,Valid BOM,0 or 1,,Integer,Valid Website Slideshow,One of: attach_files:,Valid Warehouse, -Start entering data below this line,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, -,Base Bearing Plate,Base Bearing Plate,Raw Material,Nos,1/4 in. x 6 in. x 6 in. Mild Steel Plate,Yes,No,No,No,Yes,Yes,Yes,No,No,No,No,No,,Base Bearing Plate,,,,,Stores - WP,,,,,,,,,,Eagle Hardware,,,,,,,,,,,,,,,,,, -,Base Plate,Base Plate,Raw Material,Nos,3/4 in. x 2 ft. x 4 ft. Pine Plywood,Yes,No,No,No,Yes,Yes,Yes,No,No,No,No,No,,Base Plate,,,,,Stores - WP,,,,,,,,,,HomeBase,,,,,,,,,,,,,,,,,, -,Bearing Assembly,Bearing Assembly,Sub Assemblies,Nos,Bearing Assembly,Yes,No,No,No,No,Yes,No,No,No,Yes,Yes,No,,Bearing Assembly,,,,,Stores - WP,,,0.0,,,,,,,Asiatic Solutions,,,,,,,,,,,,,,,,,, -,Bearing Block,Bearing Block,Raw Material,Nos,"CAST IRON, MCMASTER PART NO. 3710T13",Yes,No,No,No,Yes,Yes,Yes,No,No,No,No,No,,Bearing Block,,,,,Stores - WP,,,,,,,,,,Nan Duskin,,,,,,,,,,,,,,,,,, -,Bearing Collar,Bearing Collar,Raw Material,Nos,1 in. x 3 in. x 1 ft. Multipurpose Al Alloy Bar,Yes,No,No,No,Yes,Yes,Yes,No,No,No,No,No,,Bearing Collar,,,,,Stores - WP,,,,,,,,,,Eagle Hardware,,,,,,,,,,,,,,,,,, -,Bearing Pipe,Bearing Pipe,Raw Material,Nos,1.5 in. Diameter x 36 in. Mild Steel Tubing,Yes,No,No,No,Yes,Yes,Yes,No,No,No,No,No,,Bearing Pipe,,,,,Stores - WP,,,,,,,,,,HomeBase,,,,,,,,,,,,,,,,,, -,Blade Rib,Blade Rib,Raw Material,Nos,1/2 in. x 2 ft. x 4 ft. Pine Plywood,Yes,No,No,No,Yes,Yes,Yes,No,No,No,No,No,,Blade Rib,,,,,Stores - WP,,,,,,,,,,Ks Merchandise,,,,,,,,,,,,,,,,,, -,Disc Collars,Disc Collars,Raw Material,Nos,For Upper Bearing,Yes,No,No,No,Yes,Yes,Yes,No,No,No,No,No,,Disc Collars,,,,,Stores - WP,,,,,,,,,,Asiatic Solutions,,,,,,,,,,,,,,,,,, -,External Disc,External Disc,Raw Material,Nos,15/32 in. x 4 ft. x 8 ft. 3-Ply Rtd Sheathing,Yes,No,No,No,Yes,Yes,Yes,No,No,No,No,No,,External Disc,,,,,Stores - WP,,,,,,,,,,HomeBase,,,,,,,,,,,,,,,,,, -,Internal Disc,Internal Disc,Raw Material,Nos,For Bearing Collar,Yes,No,No,No,Yes,Yes,Yes,No,No,No,No,No,,Internal Disc,,,,,Stores - WP,,,,,,,,,,HomeBase,,,,,,,,,,,,,,,,,, -,Shaft,Shaft,Raw Material,Nos,1.25 in. Diameter x 6 ft. Mild Steel Tubing,Yes,No,No,No,Yes,Yes,Yes,No,No,No,No,No,,Shaft,,,,,Stores - WP,,,,,,,,,,Eagle Hardware,,,,,,,,,,,,,,,,,, -,Stand,Stand,Raw Material,Nos,N/A,Yes,No,No,No,Yes,Yes,Yes,No,No,No,No,No,,Stand,,,,,Stores - WP,,,,,,,,,,Scott Ties,,,,,,,,,,,,,,,,,, -,Upper Bearing Plate,Upper Bearing Plate,Raw Material,Nos,3/16 in. x 6 in. x 6 in. Low Carbon Steel Plate,Yes,No,No,No,Yes,Yes,Yes,No,No,No,No,No,,Upper Bearing Plate,,,,,Stores - WP,,,,,,,,,,Eagle Hardware,,,,,,,,,,,,,,,,,, -,Wind Mill A Series,Wind Mill A Series,Products,Nos,Wind Mill A Series for Home Use 9ft,Yes,No,No,Yes,Yes,Yes,Yes,No,No,Yes,Yes,No,,Wind Mill A Series,,,,,Finished Goods - WP,,,,,,,,,,,,,,,,,,,,,,,,,,,, -,Wind MIll C Series,Wind MIll C Series,Products,Nos,Wind Mill C Series for Commercial Use 18ft,Yes,No,No,Yes,Yes,Yes,Yes,No,No,Yes,Yes,No,,Wind MIll C Series,,,,,Finished Goods - WP,,,,,,,,,,,,,,,,,,,,,,,,,,,, -,Wind Turbine,Wind Turbine,Products,Nos,Small Wind Turbine for Home Use,Yes,No,No,No,Yes,Yes,Yes,No,No,Yes,Yes,No,,Wind Turbine,,,,,Finished Goods - WP,,,,,,,,,,,,,,,,,,,,,,,,,,,, -,Wing Sheet,Wing Sheet,Raw Material,Nos,1/32 in. x 24 in. x 47 in. HDPE Opaque Sheet,Yes,No,No,No,Yes,Yes,Yes,No,No,No,No,No,,Wing Sheet,,,,,Stores - WP,,,,,,,,,,New World Realty,,,,,,,,,,,,,,,,,, \ No newline at end of file +Data Import Template,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +Table:,Item,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +Notes:,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +Please do not change the template headings.,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +First data column must be blank.,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +"If you are uploading new records, leave the ""name"" (ID) column blank.",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +"If you are uploading new records, ""Naming Series"" becomes mandatory, if present.",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +Only mandatory fields are necessary for new records. You can delete non-mandatory columns if you wish.,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +"For updating, you can update only selective columns.",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +You can only upload upto 5000 records in one go. (may be less in some cases),,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +DocType:,Item,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,-,Item Reorder,item_reorder,,,,-,UOM Conversion Detail,uom_conversion_details,,-,Item Supplier,item_supplier_details,,-,Item Customer Detail,item_customer_details,,-,Item Tax,item_tax,,-,Item Price,ref_rate_details,,,,-,Item Quality Inspection Parameter,item_specification_details,,-,Website Item Group,website_item_groups,-,Item Website Specification,item_website_specifications, +Column Labels:,ID,Last Updated On,Item Name,Item Group,Default Unit of Measure,Description,Is Stock Item,Is Asset Item,Has Batch No,Has Serial No,Is Purchase Item,Is Sales Item,Is Service Item,Allow Samples,Inspection Required,Allow Bill of Materials,Allow Production Order,Is Sub Contracted Item,Document Numbering Series,Item Code,Brand,Barcode,Image,Description HTML,Default Warehouse,Allowance Percent,Valuation Method,Minimum Order Qty,Serial Number Series,Warranty Period (in days),End of Life,Net Weight,Weight UOM,Re-Order Level,Re-Order Qty,Default Supplier,Lead Time Days,Default Expense Account,Default Cost Center,Last Purchase Rate,Standard Rate,Manufacturer,Manufacturer Part Number,Max Discount (%),Default Income Account,Cost Center,Default BOM,Show in Website,Page Name,Weightage,Slideshow,Image,Website Warehouse,Website Description,-,ID,Warehouse,Re-order Level,Material Request Type,Re-order Qty,-,ID,UOM,Conversion Factor,-,ID,Supplier,Supplier Part Number,-,ID,Customer Name,Ref Code,-,ID,Tax,Tax Rate,-,ID,Price List Name,Ref Rate,Valid for Buying or Selling?,Currency,-,ID,Parameter,Acceptance Criteria,-,ID,Item Group,-,ID,Label,Description +Column Name:,name,modified,item_name,item_group,stock_uom,description,is_stock_item,is_asset_item,has_batch_no,has_serial_no,is_purchase_item,is_sales_item,is_service_item,is_sample_item,inspection_required,is_manufactured_item,is_pro_applicable,is_sub_contracted_item,naming_series,item_code,brand,barcode,image,description_html,default_warehouse,tolerance,valuation_method,min_order_qty,serial_no_series,warranty_period,end_of_life,net_weight,weight_uom,re_order_level,re_order_qty,default_supplier,lead_time_days,purchase_account,cost_center,last_purchase_rate,standard_rate,manufacturer,manufacturer_part_no,max_discount,default_income_account,default_sales_cost_center,default_bom,show_in_website,page_name,weightage,slideshow,website_image,website_warehouse,web_long_description,-,name,warehouse,warehouse_reorder_level,material_request_type,warehouse_reorder_qty,-,name,uom,conversion_factor,-,name,supplier,supplier_part_no,-,name,customer_name,ref_code,-,name,tax_type,tax_rate,-,name,price_list,ref_rate,buying_or_selling,ref_currency,-,name,specification,value,-,name,item_group,-,name,label,description +Mandatory:,Yes,Yes,Yes,Yes,Yes,Yes,Yes,Yes,Yes,Yes,Yes,Yes,Yes,Yes,Yes,Yes,Yes,Yes,No,No,No,No,No,No,No,No,No,No,No,No,No,No,No,No,No,No,No,No,No,No,No,No,No,No,No,No,No,No,No,No,No,No,No,No,-,Yes,Yes,Yes,Yes,No,-,Yes,No,No,-,Yes,No,No,-,Yes,Yes,Yes,-,Yes,Yes,No,-,Yes,Yes,Yes,Yes,No,-,Yes,Yes,No,-,Yes,No,-,Yes,No,No +Type:,Data (text),Data,Data,Link,Link,Small Text,Select,Select,Select,Select,Select,Select,Select,Select,Select,Select,Select,Select,Select,Data,Link,Data,Select,Small Text,Link,Float,Select,Float,Data,Data,Date,Float,Link,Float,Float,Link,Int,Link,Link,Float,Float,Data,Data,Float,Link,Link,Link,Check,Data,Int,Link,Select,Link,Text Editor,-,Data,Link,Float,Select,Float,-,Data,Link,Float,-,Data,Link,Data,-,Data,Link,Data,-,Data,Link,Float,-,Data,Link,Currency,Select,Link,-,Data,Data,Data,-,Data,Link,-,Data,Data,Text +Info:,,Don't change!,,Valid Item Group,Valid UOM,,"One of: Yes, No","One of: Yes, No","One of: Yes, No","One of: Yes, No","One of: Yes, No","One of: Yes, No","One of: Yes, No","One of: Yes, No","One of: Yes, No","One of: Yes, No","One of: Yes, No","One of: Yes, No",One of: ITEM,,Valid Brand,,One of: attach_files:,,Valid Warehouse,,"One of: FIFO, Moving Average",,,,,,Valid UOM,,,Valid Supplier,Integer,Valid Account,Valid Cost Center,,,,,,Valid Account,Valid Cost Center,Valid BOM,0 or 1,,Integer,Valid Website Slideshow,One of: attach_files:,Valid Warehouse,,-,Leave blank for new records,Valid Warehouse,,"One of: Purchase, Transfer",,-,Leave blank for new records,Valid UOM,,-,Leave blank for new records,Valid Supplier,,-,Leave blank for new records,Valid Customer,,-,Leave blank for new records,Valid Account,,-,Leave blank for new records,Valid Price List,,"One of: Buying, Selling",Valid Currency,-,Leave blank for new records,,,-,Leave blank for new records,Valid Item Group,-,Leave blank for new records,, +Start entering data below this line,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +,Base Bearing Plate,"""2013-08-20 11:11:53""",Base Bearing Plate,Raw Material,Nos,1/4 in. x 6 in. x 6 in. Mild Steel Plate,Yes,No,No,No,Yes,Yes,Yes,No,No,No,No,No,,Base Bearing Plate,,,,,Stores - WP,0.0,,0.0,,,,0.0,,0.0,0.0,Eagle Hardware,0,,,15.0,0.0,,,0.0,,,,0,,0,,,,,,,,,,,,UCDD/00001,Nos,1.0,,,,,,,,,,,,,,RFD/00001,Standard Buying,15.0,Buying,USD,,,,,,,,,,, +,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,RFD/00017,Standard Selling,21.0,Selling,USD,,,,,,,,,,, +,Base Plate,"""2013-08-20 11:11:53""",Base Plate,Raw Material,Nos,3/4 in. x 2 ft. x 4 ft. Pine Plywood,Yes,No,No,No,Yes,Yes,Yes,No,No,No,No,No,,Base Plate,,,,,Stores - WP,0.0,,0.0,,,,0.0,,0.0,0.0,HomeBase,0,,,20.0,0.0,,,0.0,,,,0,,0,,,,,,,,,,,,UCDD/00002,Nos,1.0,,,,,,,,,,,,,,RFD/00002,Standard Buying,20.0,Buying,USD,,,,,,,,,,, +,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,RFD/00018,Standard Selling,28.0,Selling,USD,,,,,,,,,,, +,Bearing Assembly,"""2013-08-20 11:11:55""",Bearing Assembly,Sub Assemblies,Nos,Bearing Assembly,Yes,No,No,No,No,Yes,No,No,No,Yes,Yes,No,,Bearing Assembly,,,,,Stores - WP,0.0,,0.0,,,,0.0,,0.0,0.0,Asiatic Solutions,0,,,0.0,0.0,,,0.0,,,,0,,0,,,,,,,,,,,,UCDD/00003,Nos,1.0,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +,Bearing Block,"""2013-08-20 11:11:54""",Bearing Block,Raw Material,Nos,"CAST IRON, MCMASTER PART NO. 3710T13",Yes,No,No,No,Yes,Yes,Yes,No,No,No,No,No,,Bearing Block,,,,,Stores - WP,0.0,,0.0,,,,0.0,,0.0,0.0,Nan Duskin,0,,,10.0,0.0,,,0.0,,,,0,,0,,,,,,,,,,,,UCDD/00004,Nos,1.0,,,,,,,,,,,,,,RFD/00003,Standard Buying,10.0,Buying,USD,,,,,,,,,,, +,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,RFD/00019,Standard Selling,14.0,Selling,USD,,,,,,,,,,, +,Bearing Collar,"""2013-08-20 11:11:54""",Bearing Collar,Raw Material,Nos,1 in. x 3 in. x 1 ft. Multipurpose Al Alloy Bar,Yes,No,No,No,Yes,Yes,Yes,No,No,No,No,No,,Bearing Collar,,,,,Stores - WP,0.0,,0.0,,,,0.0,,0.0,0.0,Eagle Hardware,0,,,20.0,0.0,,,0.0,,,,0,,0,,,,,,,,,,,,UCDD/00005,Nos,1.0,,,,,,,,,,,,,,RFD/00004,Standard Buying,20.0,Buying,USD,,,,,,,,,,, +,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,RFD/00020,Standard Selling,28.0,Selling,USD,,,,,,,,,,, +,Bearing Pipe,"""2013-08-20 11:11:54""",Bearing Pipe,Raw Material,Nos,1.5 in. Diameter x 36 in. Mild Steel Tubing,Yes,No,No,No,Yes,Yes,Yes,No,No,No,No,No,,Bearing Pipe,,,,,Stores - WP,0.0,,0.0,,,,0.0,,0.0,0.0,HomeBase,0,,,15.0,0.0,,,0.0,,,,0,,0,,,,,,,,,,,,UCDD/00006,Nos,1.0,,,,,,,,,,,,,,RFD/00005,Standard Buying,15.0,Buying,USD,,,,,,,,,,, +,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,RFD/00021,Standard Selling,21.0,Selling,USD,,,,,,,,,,, +,Blade Rib,"""2013-08-20 11:11:54""",Blade Rib,Raw Material,Nos,1/2 in. x 2 ft. x 4 ft. Pine Plywood,Yes,No,No,No,Yes,Yes,Yes,No,No,No,No,No,,Blade Rib,,,,,Stores - WP,0.0,,0.0,,,,0.0,,0.0,0.0,Ks Merchandise,0,,,0.0,0.0,,,0.0,,,,0,,0,,,,,,,,,,,,UCDD/00007,Nos,1.0,,,,,,,,,,,,,,RFD/00006,Standard Buying,10.0,Buying,USD,,,,,,,,,,, +,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,RFD/00022,Standard Selling,14.0,Selling,USD,,,,,,,,,,, +,Disc Collars,"""2013-08-20 11:11:54""",Disc Collars,Raw Material,Nos,For Upper Bearing,Yes,No,No,No,Yes,Yes,Yes,No,No,No,No,No,,Disc Collars,,,,,Stores - WP,0.0,,0.0,,,,0.0,,0.0,0.0,Asiatic Solutions,0,,,0.0,0.0,,,0.0,,,,0,,0,,,,,,,,,,,,UCDD/00008,Nos,1.0,,,,,,,,,,,,,,RFD/00007,Standard Buying,74.0,Buying,USD,,,,,,,,,,, +,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,RFD/00023,Standard Selling,103.6,Selling,USD,,,,,,,,,,, +,External Disc,"""2013-08-20 11:11:54""",External Disc,Raw Material,Nos,15/32 in. x 4 ft. x 8 ft. 3-Ply Rtd Sheathing,Yes,No,No,No,Yes,Yes,Yes,No,No,No,No,No,,External Disc,,,,,Stores - WP,0.0,,0.0,,,,0.0,,0.0,0.0,HomeBase,0,,,45.0,0.0,,,0.0,,,,0,,0,,,,,,,,,,,,UCDD/00009,Nos,1.0,,,,,,,,,,,,,,RFD/00008,Standard Buying,45.0,Buying,USD,,,,,,,,,,, +,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,RFD/00024,Standard Selling,63.0,Selling,USD,,,,,,,,,,, +,Internal Disc,"""2013-08-20 11:11:54""",Internal Disc,Raw Material,Nos,For Bearing Collar,Yes,No,No,No,Yes,Yes,Yes,No,No,No,No,No,,Internal Disc,,,,,Stores - WP,0.0,,0.0,,,,0.0,,0.0,0.0,HomeBase,0,,,33.0,0.0,,,0.0,,,,0,,0,,,,,,,,,,,,UCDD/00010,Nos,1.0,,,,,,,,,,,,,,RFD/00009,Standard Buying,33.0,Buying,USD,,,,,,,,,,, +,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,RFD/00025,Standard Selling,46.2,Selling,USD,,,,,,,,,,, +,Shaft,"""2013-08-20 11:11:54""",Shaft,Raw Material,Nos,1.25 in. Diameter x 6 ft. Mild Steel Tubing,Yes,No,No,No,Yes,Yes,Yes,No,No,No,No,No,,Shaft,,,,,Stores - WP,0.0,,0.0,,,,0.0,,0.0,0.0,Eagle Hardware,0,,,30.0,0.0,,,0.0,,,,0,,0,,,,,,,,,,,,UCDD/00011,Nos,1.0,,,,,,,,,,,,,,RFD/00010,Standard Buying,30.0,Buying,USD,,,,,,,,,,, +,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,RFD/00026,Standard Selling,42.0,Selling,USD,,,,,,,,,,, +,Stand,"""2013-08-20 11:11:54""",Stand,Raw Material,Nos,N/A,Yes,No,No,No,Yes,Yes,Yes,No,No,No,No,No,,Stand,,,,,Stores - WP,0.0,,0.0,,,,0.0,,0.0,0.0,Scott Ties,0,,,0.0,0.0,,,0.0,,,,0,,0,,,,,,,,,,,,UCDD/00012,Nos,1.0,,,,,,,,,,,,,,RFD/00011,Standard Buying,40.0,Buying,USD,,,,,,,,,,, +,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,RFD/00027,Standard Selling,56.0,Selling,USD,,,,,,,,,,, +,Upper Bearing Plate,"""2013-08-20 11:11:54""",Upper Bearing Plate,Raw Material,Nos,3/16 in. x 6 in. x 6 in. Low Carbon Steel Plate,Yes,No,No,No,Yes,Yes,Yes,No,No,No,No,No,,Upper Bearing Plate,,,,,Stores - WP,0.0,,0.0,,,,0.0,,0.0,0.0,Eagle Hardware,0,,,50.0,0.0,,,0.0,,,,0,,0,,,,,,,,,,,,UCDD/00013,Nos,1.0,,,,,,,,,,,,,,RFD/00012,Standard Buying,50.0,Buying,USD,,,,,,,,,,, +,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,RFD/00028,Standard Selling,70.0,Selling,USD,,,,,,,,,,, +,Wind Mill A Series,"""2013-08-20 11:27:46""",Wind Mill A Series,Products,Nos,Wind Mill A Series for Home Use 9ft,Yes,No,No,Yes,No,Yes,Yes,No,No,Yes,Yes,No,,Wind Mill A Series,,,,,Finished Goods - WP,0.0,,0.0,WMA,,,0.0,,0.0,0.0,,0,,,0.0,0.0,,,0.0,,,,0,,0,,,,,,,,,,,,UCDD/00014,Nos,1.0,,,,,,,,,,,,,,RFD/00015,Standard Selling,340.0,Selling,USD,,,,,,,,,,, +,Wind MIll C Series,"""2013-08-20 11:27:27""",Wind MIll C Series,Products,Nos,Wind Mill C Series for Commercial Use 18ft,Yes,No,No,Yes,No,Yes,Yes,No,No,Yes,Yes,No,,Wind MIll C Series,,,,,Finished Goods - WP,0.0,,0.0,WMC,,,0.0,,0.0,0.0,,0,,,0.0,0.0,,,0.0,,,,0,,0,,,,,,,,,,,,UCDD/00015,Nos,1.0,,,,,,,,,,,,,,RFD/00016,Standard Selling,400.0,Selling,USD,,,,,,,,,,, +,Wind Turbine,"""2013-08-20 11:29:26""",Wind Turbine,Products,Nos,Small Wind Turbine for Home Use,Yes,No,No,Yes,No,Yes,Yes,No,No,Yes,Yes,No,,Wind Turbine,,,,,Finished Goods - WP,0.0,,0.0,WTU,,,0.0,,0.0,0.0,,0,,,0.0,0.0,,,0.0,,,,0,,0,,,,,,,,,,,,UCDD/00016,Nos,1.0,,,,,,,,,,,,,,RFD/00014,Standard Selling,300.0,Selling,USD,,,,,,,,,,, +,Wing Sheet,"""2013-08-20 11:11:55""",Wing Sheet,Raw Material,Nos,1/32 in. x 24 in. x 47 in. HDPE Opaque Sheet,Yes,No,No,No,Yes,Yes,Yes,No,No,No,No,No,,Wing Sheet,,,,,Stores - WP,0.0,,0.0,,,,0.0,,0.0,0.0,New World Realty,0,,,22.0,0.0,,,0.0,,,,0,,0,,,,,,,,,,,,UCDD/00017,Nos,1.0,,,,,,,,,,,,,,RFD/00013,Standard Buying,22.0,Buying,USD,,,,,,,,,,, +,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,RFD/00029,Standard Selling,30.8,Selling,USD,,,,,,,,,,, \ No newline at end of file diff --git a/utilities/make_demo.py b/utilities/make_demo.py index 600faaa220f..2dda953e1a6 100644 --- a/utilities/make_demo.py +++ b/utilities/make_demo.py @@ -14,14 +14,15 @@ from core.page.data_import_tool.data_import_tool import upload # fix fiscal year company = "Wind Power LLC" +country = "United States" +currency = "USD" +time_zone = "America/New York" start_date = '2010-01-01' runs_for = 20 prob = { - "Quotation": { "make": 0.5, "qty": (1,5) }, - "Sales Order": { "make": 0.5, "qty": (1,4) }, - "Purchase Order": { "make": 0.7, "qty": (1,4) }, - "Purchase Receipt": { "make": 0.7, "qty": (1,4) }, - "Supplier Quotation": { "make": 0.5, "qty": (1, 3) } + "default": { "make": 0.6, "qty": (1,5) }, + "Purchase Order": { "make": 0.7, "qty": (1,15) }, + "Purchase Receipt": { "make": 0.7, "qty": (1,15) }, } def make(reset=False): @@ -46,12 +47,18 @@ def setup(): def simulate(): current_date = None for i in xrange(runs_for): - print i if not current_date: - current_date = webnotes.utils.getdate(start_date) + # get last stock ledger posting date or use default + last_posting = webnotes.conn.sql("""select max(posting_date) from `tabStock Ledger Entry`""") + if last_posting[0][0]: + current_date = webnotes.utils.add_days(last_posting[0][0], 1) + else: + current_date = webnotes.utils.getdate(start_date) else: current_date = webnotes.utils.add_days(current_date, 1) - + + print current_date.strftime("%Y-%m-%d") + if current_date.weekday() in (5, 6): continue @@ -85,17 +92,48 @@ def run_stock(current_date): # make delivery notes (if possible) if can_make("Delivery Note"): from selling.doctype.sales_order.sales_order import make_delivery_note + from stock.stock_ledger import NegativeStockError + from stock.doctype.stock_ledger_entry.stock_ledger_entry import SerialNoRequiredError, SerialNoQtyError report = "Ordered Items To Be Delivered" for so in list(set([r[0] for r in query_report.run(report)["result"] if r[0]!="Total"]))[:how_many("Delivery Note")]: dn = webnotes.bean(make_delivery_note(so)) dn.doc.posting_date = current_date dn.doc.fiscal_year = "2010" dn.insert() - dn.submit() - webnotes.conn.commit() + try: + dn.submit() + webnotes.conn.commit() + except NegativeStockError: pass + except SerialNoRequiredError: pass + except SerialNoQtyError: pass + + # try submitting existing + for dn in webnotes.conn.get_values("Delivery Note", {"docstatus": 0}, "name"): + b = webnotes.bean("Delivery Note", dn[0]) + b.submit() + webnotes.conn.commit() + def run_purchase(current_date): + # make material requests for purchase items that have negative projected qtys + if can_make("Material Request"): + report = "Items To Be Requested" + for row in query_report.run(report)["result"][:how_many("Material Request")]: + mr = webnotes.new_bean("Material Request") + mr.doc.material_request_type = "Purchase" + mr.doc.transaction_date = current_date + mr.doc.fiscal_year = "2010" + mr.doclist.append({ + "doctype": "Material Request Item", + "parentfield": "indent_details", + "schedule_date": webnotes.utils.add_days(current_date, 7), + "item_code": row[0], + "qty": -row[-1] + }) + mr.insert() + mr.submit() + # make supplier quotations if can_make("Supplier Quotation"): from stock.doctype.material_request.material_request import make_supplier_quotation @@ -124,7 +162,7 @@ def run_purchase(current_date): def run_manufacturing(current_date): from stock.stock_ledger import NegativeStockError - from stock.doctype.stock_entry.stock_entry import IncorrectValuationRateError + from stock.doctype.stock_entry.stock_entry import IncorrectValuationRateError, DuplicateEntryForProductionOrderError ppt = webnotes.bean("Production Planning Tool", "Production Planning Tool") ppt.doc.company = company @@ -137,14 +175,14 @@ def run_manufacturing(current_date): webnotes.conn.commit() # submit production orders - for pro in webnotes.conn.get_values("Production Order", {"docstatus": 0}): + for pro in webnotes.conn.get_values("Production Order", {"docstatus": 0}, "name"): b = webnotes.bean("Production Order", pro[0]) b.doc.wip_warehouse = "Work in Progress - WP" b.submit() webnotes.conn.commit() # submit material requests - for pro in webnotes.conn.get_values("Material Request", {"docstatus": 0}): + for pro in webnotes.conn.get_values("Material Request", {"docstatus": 0}, "name"): b = webnotes.bean("Material Request", pro[0]) b.submit() webnotes.conn.commit() @@ -160,31 +198,32 @@ def run_manufacturing(current_date): make_stock_entry_from_pro(pro[0], "Manufacture/Repack", current_date) # try posting older drafts (if exists) - for st in webnotes.conn.get_values("Stock Entry", {"docstatus":0}): + for st in webnotes.conn.get_values("Stock Entry", {"docstatus":0}, "name"): try: webnotes.bean("Stock Entry", st[0]).submit() webnotes.conn.commit() except NegativeStockError: pass except IncorrectValuationRateError: pass - + except DuplicateEntryForProductionOrderError: pass def make_stock_entry_from_pro(pro_id, purpose, current_date): from manufacturing.doctype.production_order.production_order import make_stock_entry from stock.stock_ledger import NegativeStockError - from stock.doctype.stock_entry.stock_entry import IncorrectValuationRateError + from stock.doctype.stock_entry.stock_entry import IncorrectValuationRateError, DuplicateEntryForProductionOrderError st = webnotes.bean(make_stock_entry(pro_id, purpose)) - st.run_method("get_items") st.doc.posting_date = current_date st.doc.fiscal_year = "2010" st.doc.expense_adjustment_account = "Stock in Hand - WP" try: + st.run_method("get_items") st.insert() webnotes.conn.commit() st.submit() webnotes.conn.commit() except NegativeStockError: pass except IncorrectValuationRateError: pass + except DuplicateEntryForProductionOrderError: pass def make_quotation(current_date): b = webnotes.bean([{ @@ -253,10 +292,10 @@ def get_random(doctype, filters=None): return out and out[0][0] or None def can_make(doctype): - return random.random() < prob.get(doctype, {"make": 0.5})["make"] + return random.random() < prob.get(doctype, prob["default"])["make"] def how_many(doctype): - return random.randrange(*prob.get(doctype, {"qty": (1, 3)})["qty"]) + return random.randrange(*prob.get(doctype, prob["default"])["qty"]) def install(): print "Creating Fresh Database..." @@ -273,15 +312,15 @@ def complete_setup(): "industry": "Manufacturing", "company_name": company, "company_abbr": "WP", - "currency": "USD", - "timezone": "America/New York", - "country": "United States" + "currency": currency, + "timezone": time_zone, + "country": country }) import_data("Fiscal_Year") def make_items(): - import_data(["Item", "Item_Price"]) + import_data("Item") import_data("BOM", submit=True) def make_customers_suppliers_contacts(): From f83cf5890e69e16eff6486324bff645f4f11c2ce Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Tue, 20 Aug 2013 15:36:10 +0530 Subject: [PATCH 02/10] [fix] [minor] setup serial no editor if serial no field exists --- public/js/utils.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/public/js/utils.js b/public/js/utils.js index c2f2364fbfb..61e613bdecb 100644 --- a/public/js/utils.js +++ b/public/js/utils.js @@ -38,7 +38,8 @@ $.extend(erpnext, { }, setup_serial_no: function(grid_row) { - if(grid_row.fields_dict.serial_no.get_status()!=="Write") return; + if(!grid_row.fields_dict.serial_no || + grid_row.fields_dict.serial_no.get_status()!=="Write") return; var $btn = $('') .appendTo($("
") From a7a919d721ab7b3f71256920ec1e574288479ee3 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Tue, 20 Aug 2013 16:13:23 +0530 Subject: [PATCH 03/10] [fix] [minor] set warranty expiry date on serial no from delivery note --- stock/doctype/delivery_note/delivery_note.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stock/doctype/delivery_note/delivery_note.py b/stock/doctype/delivery_note/delivery_note.py index 6e44f04254e..7c839b6d58e 100644 --- a/stock/doctype/delivery_note/delivery_note.py +++ b/stock/doctype/delivery_note/delivery_note.py @@ -4,7 +4,7 @@ from __future__ import unicode_literals import webnotes -from webnotes.utils import cstr, flt, cint +from webnotes.utils import cstr, flt, cint, add_days from webnotes.model.bean import getlist from webnotes.model.code import get_obj from webnotes import msgprint, _ @@ -236,7 +236,7 @@ class DocType(SellingController): sr.doc.customer = self.doc.customer sr.doc.customer_name = self.doc.customer_name if sr.doc.warranty_period: - sr.doc.warranty_expiry_date = add_days(cstr(self.doc.delivery_date), + sr.doc.warranty_expiry_date = add_days(cstr(self.doc.posting_date), cint(sr.doc.warranty_period)) sr.doc.status = 'Delivered' From 4aeee45530e1beda485b198992947f25bc376639 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Tue, 20 Aug 2013 17:09:05 +0530 Subject: [PATCH 04/10] [fix] [minor] get items from bom on material transfer against production order --- stock/doctype/stock_entry/stock_entry.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/stock/doctype/stock_entry/stock_entry.js b/stock/doctype/stock_entry/stock_entry.js index 529cb625349..8843a35fe8f 100644 --- a/stock/doctype/stock_entry/stock_entry.js +++ b/stock/doctype/stock_entry/stock_entry.js @@ -104,11 +104,11 @@ erpnext.stock.StockEntry = erpnext.stock.StockController.extend({ callback: function(r) { if (!r.exc) me.frm.set_value("expense_adjustment_account", r.message); - me.get_items(); + me.get_items_onload(); } }); } else { - me.get_items(); + me.get_items_onload(); } }, @@ -121,6 +121,13 @@ erpnext.stock.StockEntry = erpnext.stock.StockController.extend({ } }, + get_items_onload: function() { + if (this.frm.doc.__islocal && !getchildren('Stock Entry Detail', this.frm.doc.name, + 'mtn_details').length) { + this.get_items() + } + }, + get_items: function() { if(this.frm.doc.production_order || this.frm.doc.bom_no) { // if production order / bom is mentioned, get items From 7bd850a133871ab5bf778030d29dcb62209ed2a4 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Tue, 20 Aug 2013 17:40:26 +0530 Subject: [PATCH 05/10] [patch] [minor] fix sle against cancelled stock entry for production --- .../production_order/production_order.py | 3 ++- .../p06_fix_sle_against_stock_entry.py | 23 +++++++++++++++++++ patches/patch_list.py | 1 + stock/doctype/stock_entry/stock_entry.js | 11 --------- 4 files changed, 26 insertions(+), 12 deletions(-) create mode 100644 patches/august_2013/p06_fix_sle_against_stock_entry.py diff --git a/manufacturing/doctype/production_order/production_order.py b/manufacturing/doctype/production_order/production_order.py index 6cdbc2f046a..6a133e78fa0 100644 --- a/manufacturing/doctype/production_order/production_order.py +++ b/manufacturing/doctype/production_order/production_order.py @@ -162,5 +162,6 @@ def make_stock_entry(production_order_id, purpose): else: stock_entry.doc.from_warehouse = production_order.doc.wip_warehouse stock_entry.doc.to_warehouse = production_order.doc.fg_warehouse - + + stock_entry.run_method("get_items") return [d.fields for d in stock_entry.doclist] diff --git a/patches/august_2013/p06_fix_sle_against_stock_entry.py b/patches/august_2013/p06_fix_sle_against_stock_entry.py new file mode 100644 index 00000000000..4413eeaa094 --- /dev/null +++ b/patches/august_2013/p06_fix_sle_against_stock_entry.py @@ -0,0 +1,23 @@ +import webnotes +def execute(): + from stock.stock_ledger import update_entries_after + + stock_entries = webnotes.conn.sql("""select name from `tabStock Entry` + where docstatus < 2 and modified >= '2013-08-15' + and ifnull(production_order, '') != '' and ifnull(bom_no, '') != ''""") + + for entry in stock_entries: + webnotes.conn.sql("""update `tabStock Ledger Entry` set is_cancelled = 'Yes' + where voucher_type = 'Stock Entry' and voucher_no = %s""", entry[0]) + + item_warehouse = webnotes.conn.sql("""select distinct item_code, warehouse + from `tabStock Ledger Entry` + where voucher_type = 'Stock Entry' and voucher_no = %s""", entry[0], as_dict=1) + + for d in item_warehouse: + update_entries_after({ + "item_code": d.item_code, + "warehouse": d.warehouse, + "posting_date": "2013-08-15", + "posting_date": "01:00" + }) \ No newline at end of file diff --git a/patches/patch_list.py b/patches/patch_list.py index 41160aad67b..3dc6c76401b 100644 --- a/patches/patch_list.py +++ b/patches/patch_list.py @@ -256,4 +256,5 @@ patch_list = [ "patches.august_2013.p05_update_serial_no_status", "patches.august_2013.p05_employee_birthdays", "execute:webnotes.reload_doc('accounts', 'Print Format', 'POS Invoice') # 2013-08-16", + "patches.august_2013.p06_fix_sle_against_stock_entry", ] \ No newline at end of file diff --git a/stock/doctype/stock_entry/stock_entry.js b/stock/doctype/stock_entry/stock_entry.js index 8843a35fe8f..e3690817267 100644 --- a/stock/doctype/stock_entry/stock_entry.js +++ b/stock/doctype/stock_entry/stock_entry.js @@ -103,12 +103,8 @@ erpnext.stock.StockEntry = erpnext.stock.StockController.extend({ }, callback: function(r) { if (!r.exc) me.frm.set_value("expense_adjustment_account", r.message); - - me.get_items_onload(); } }); - } else { - me.get_items_onload(); } }, @@ -121,13 +117,6 @@ erpnext.stock.StockEntry = erpnext.stock.StockController.extend({ } }, - get_items_onload: function() { - if (this.frm.doc.__islocal && !getchildren('Stock Entry Detail', this.frm.doc.name, - 'mtn_details').length) { - this.get_items() - } - }, - get_items: function() { if(this.frm.doc.production_order || this.frm.doc.bom_no) { // if production order / bom is mentioned, get items From eb9194f66d5fa002a11e77e7886debdb5336c902 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Tue, 20 Aug 2013 18:10:44 +0530 Subject: [PATCH 06/10] [fix] [minor] remove fix patch --- patches/patch_list.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/patches/patch_list.py b/patches/patch_list.py index 3dc6c76401b..c7ec0c9d25a 100644 --- a/patches/patch_list.py +++ b/patches/patch_list.py @@ -256,5 +256,5 @@ patch_list = [ "patches.august_2013.p05_update_serial_no_status", "patches.august_2013.p05_employee_birthdays", "execute:webnotes.reload_doc('accounts', 'Print Format', 'POS Invoice') # 2013-08-16", - "patches.august_2013.p06_fix_sle_against_stock_entry", + # "patches.august_2013.p06_fix_sle_against_stock_entry", ] \ No newline at end of file From fe14f69e71f0c4a5b121be139905afd4c14de2b7 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Tue, 20 Aug 2013 20:06:14 +0530 Subject: [PATCH 07/10] [fix] [patch] [minor] sle for deleted stock entry detail --- .../p06_fix_sle_against_stock_entry.py | 132 +++++++++++++++--- 1 file changed, 114 insertions(+), 18 deletions(-) diff --git a/patches/august_2013/p06_fix_sle_against_stock_entry.py b/patches/august_2013/p06_fix_sle_against_stock_entry.py index 4413eeaa094..dbc2c94ecf4 100644 --- a/patches/august_2013/p06_fix_sle_against_stock_entry.py +++ b/patches/august_2013/p06_fix_sle_against_stock_entry.py @@ -1,23 +1,119 @@ import webnotes + +cancelled = [] +uncancelled = [] + def execute(): from stock.stock_ledger import update_entries_after - - stock_entries = webnotes.conn.sql("""select name from `tabStock Entry` - where docstatus < 2 and modified >= '2013-08-15' - and ifnull(production_order, '') != '' and ifnull(bom_no, '') != ''""") - + + stock_entries = webnotes.conn.sql("""select * from `tabStock Entry` + where docstatus >= 1 and date(modified) >= "2013-08-16" and date(modified) <= "2013-08-21" + and ifnull(production_order, '') != '' and ifnull(bom_no, '') != '' + order by modified desc, name desc""", as_dict=True) + for entry in stock_entries: - webnotes.conn.sql("""update `tabStock Ledger Entry` set is_cancelled = 'Yes' - where voucher_type = 'Stock Entry' and voucher_no = %s""", entry[0]) + if not webnotes.conn.sql("""select name from `tabStock Entry Detail` + where parent=%s""", entry.name): + res = webnotes.conn.sql("""select * from `tabStock Ledger Entry` + where voucher_type='Stock Entry' and voucher_no=%s + and is_cancelled='No'""", entry.name, as_dict=True) + if res: + print entry + make_stock_entry_detail(entry, res) + + if cancelled or uncancelled: + send_email() - item_warehouse = webnotes.conn.sql("""select distinct item_code, warehouse - from `tabStock Ledger Entry` - where voucher_type = 'Stock Entry' and voucher_no = %s""", entry[0], as_dict=1) - - for d in item_warehouse: - update_entries_after({ - "item_code": d.item_code, - "warehouse": d.warehouse, - "posting_date": "2013-08-15", - "posting_date": "01:00" - }) \ No newline at end of file +def make_stock_entry_detail(entry, res): + global cancelled, uncancelled + + fg_item = webnotes.conn.get_value("Production Order", entry.production_order, + "production_item") + voucher_detail_entries_map = {} + for sle in res: + voucher_detail_entries_map.setdefault(sle.voucher_detail_no, []).append(sle) + + for i, voucher_detail_no in enumerate(sorted(voucher_detail_entries_map.keys())): + sl_entries = voucher_detail_entries_map[voucher_detail_no] + # create stock entry details back from stock ledger entries + stock_entry_detail = webnotes.doc({ + "doctype": "Stock Entry Detail", + "parentfield": "mtn_details", + "parenttype": "Stock Entry", + "parent": entry.name, + "__islocal": 1, + "idx": i+1, + "docstatus": 1, + "owner": entry.owner, + "name": voucher_detail_no, + "transfer_qty": abs(sl_entries[0].actual_qty), + "qty": abs(sl_entries[0].actual_qty), + "stock_uom": sl_entries[0].stock_uom, + "uom": sl_entries[0].stock_uom, + "conversion_factor": 1, + "item_code": sl_entries[0].item_code, + "description": webnotes.conn.get_value("Item", sl_entries[0].item_code, + "description"), + "incoming_rate": sl_entries[0].incoming_rate, + "batch_no": sl_entries[0].batch_no, + "serial_no": sl_entries[0].serial_no + }) + + if sl_entries[0].item_code == fg_item: + stock_entry_detail.bom_no = entry.bom_no + + for sle in sl_entries: + if sle.actual_qty < 0: + stock_entry_detail.s_warehouse = sle.warehouse + else: + stock_entry_detail.t_warehouse = sle.warehouse + + stock_entry_detail.save() + + if entry.docstatus == 2: + webnotes.conn.set_value("Stock Entry", entry.name, "docstatus", 1) + + # call for cancelled ones + se = webnotes.bean("Stock Entry", entry.name) + controller = se.make_controller() + controller.update_production_order(1) + + res = webnotes.conn.sql("""select name from `tabStock Entry` + where amended_from=%s""", entry.name) + if res: + cancelled.append(res[0][0]) + if res[0][0] in uncancelled: + uncancelled.remove(res[0][0]) + + webnotes.bean("Stock Entry", res[0][0]).cancel() + + uncancelled.append(se.doc.name) + +def send_email(): + from webnotes.utils.email_lib import sendmail_to_system_managers + global cancelled, uncancelled + uncancelled = "we have undone the cancellation of the following Stock Entries through a patch:\n" + \ + "\n".join(uncancelled) if uncancelled else "" + cancelled = "and cancelled the following Stock Entries:\n" + "\n".join(cancelled) \ + if cancelled else "" + + subject = "[ERPNext] [Important] Cancellation undone for some Stock Entries" + content = """Dear user, + +An error got introduced into the code that cleared the item table in Stock Entry associated to a Production Order. + +Hence, +%s + +%s + +You will have to edit them again. + +Sorry for the inconvenience this has caused. + +Regards, +Team ERPNext.""" % (uncancelled, cancelled) + + print subject, content + + # sendmail_to_system_managers(subject, content) \ No newline at end of file From 691096d8b123e6af039c9000a7566174b697c36e Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Wed, 21 Aug 2013 11:07:24 +0530 Subject: [PATCH 08/10] [fix] [minor] duplicate stock entry against production order --- stock/doctype/stock_entry/stock_entry.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/stock/doctype/stock_entry/stock_entry.py b/stock/doctype/stock_entry/stock_entry.py index 014e93e3267..e3fc67e0fc9 100644 --- a/stock/doctype/stock_entry/stock_entry.py +++ b/stock/doctype/stock_entry/stock_entry.py @@ -156,7 +156,8 @@ class DocType(StockController): other_ste = [t[0] for t in webnotes.conn.get_values("Stock Entry", { "production_order": self.doc.production_order, "purpose": self.doc.purpose, - "docstatus": ["!=", 2] + "docstatus": ["!=", 2], + "name": ["!=", self.doc.name] }, "name")] if other_ste: From 82e54c829383a6ee82bf599d977d97bfea4b33ba Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Wed, 21 Aug 2013 11:19:15 +0530 Subject: [PATCH 09/10] [minor] fix to purchase receipt button, make_demo --- .../purchase_receipt/purchase_receipt.js | 31 +++++++++---------- utilities/make_demo.py | 1 - 2 files changed, 15 insertions(+), 17 deletions(-) diff --git a/stock/doctype/purchase_receipt/purchase_receipt.js b/stock/doctype/purchase_receipt/purchase_receipt.js index d0e58dfe609..8775140a8bd 100644 --- a/stock/doctype/purchase_receipt/purchase_receipt.js +++ b/stock/doctype/purchase_receipt/purchase_receipt.js @@ -23,24 +23,23 @@ erpnext.stock.PurchaseReceiptController = erpnext.buying.BuyingController.extend this.show_stock_ledger(); this.show_general_ledger(); + } else { + cur_frm.add_custom_button(wn._('From Purchase Order'), + function() { + wn.model.map_current_doc({ + method: "buying.doctype.purchase_order.purchase_order.make_purchase_receipt", + source_doctype: "Purchase Order", + get_query_filters: { + supplier: cur_frm.doc.supplier || undefined, + docstatus: 1, + status: ["!=", "Stopped"], + per_received: ["<", 99.99], + company: cur_frm.doc.company + } + }) + }); } - cur_frm.add_custom_button(wn._('From Purchase Order'), - function() { - wn.model.map_current_doc({ - method: "buying.doctype.purchase_order.purchase_order.make_purchase_receipt", - source_doctype: "Purchase Order", - get_query_filters: { - supplier: cur_frm.doc.supplier || undefined, - docstatus: 1, - status: ["!=", "Stopped"], - per_received: ["<", 99.99], - company: cur_frm.doc.company - } - }) - }); - - if(wn.boot.control_panel.country == 'India') { unhide_field(['challan_no', 'challan_date']); } diff --git a/utilities/make_demo.py b/utilities/make_demo.py index 2dda953e1a6..d1758a034e8 100644 --- a/utilities/make_demo.py +++ b/utilities/make_demo.py @@ -216,7 +216,6 @@ def make_stock_entry_from_pro(pro_id, purpose, current_date): st.doc.fiscal_year = "2010" st.doc.expense_adjustment_account = "Stock in Hand - WP" try: - st.run_method("get_items") st.insert() webnotes.conn.commit() st.submit() From 945aff14686e6ce7efadbe22f2bb84e8419e1415 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Wed, 21 Aug 2013 11:28:45 +0530 Subject: [PATCH 10/10] [fix] [minor] fiscal year deleted from serial no --- stock/doctype/serial_no/serial_no.txt | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/stock/doctype/serial_no/serial_no.txt b/stock/doctype/serial_no/serial_no.txt index c3746eb2961..e07ab282537 100644 --- a/stock/doctype/serial_no/serial_no.txt +++ b/stock/doctype/serial_no/serial_no.txt @@ -2,7 +2,7 @@ { "creation": "2013-05-16 10:59:15", "docstatus": 0, - "modified": "2013-08-16 10:16:00", + "modified": "2013-08-21 11:22:50", "modified_by": "Administrator", "owner": "Administrator" }, @@ -446,17 +446,6 @@ "reqd": 1, "search_index": 1 }, - { - "doctype": "DocField", - "fieldname": "fiscal_year", - "fieldtype": "Select", - "in_filter": 1, - "label": "Fiscal Year", - "options": "link:Fiscal Year", - "read_only": 0, - "reqd": 1, - "search_index": 1 - }, { "cancel": 1, "create": 1,