From a4f6529801ef23f6539f0d86d30708a4fcb7365e Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Mon, 6 Aug 2012 13:42:19 +0530 Subject: [PATCH 01/23] in item's update page name, if item name is null, create page name with only the name --- erpnext/stock/doctype/item/item.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/stock/doctype/item/item.py b/erpnext/stock/doctype/item/item.py index 85069ef872..6a0f200698 100644 --- a/erpnext/stock/doctype/item/item.py +++ b/erpnext/stock/doctype/item/item.py @@ -223,7 +223,7 @@ class DocType: import website.utils # if same name, do not repeat twice - if self.doc.name == self.doc.item_name: + if self.doc.name == self.doc.item_name or not self.doc.item_name: page_name = self.doc.name else: page_name = self.doc.name + " " + self.doc.item_name From ed8049ec19a5276c9077a1ca2070b27b050a1e27 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Mon, 6 Aug 2012 14:31:45 +0530 Subject: [PATCH 02/23] fixes in patch: considered over delivery in reserved qty calculation --- .../july_2012/repost_stock_due_to_wrong_packing_list.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/erpnext/patches/july_2012/repost_stock_due_to_wrong_packing_list.py b/erpnext/patches/july_2012/repost_stock_due_to_wrong_packing_list.py index 3b21ca6102..be4d4502e6 100644 --- a/erpnext/patches/july_2012/repost_stock_due_to_wrong_packing_list.py +++ b/erpnext/patches/july_2012/repost_stock_due_to_wrong_packing_list.py @@ -40,7 +40,8 @@ def repost_reserved_qty(): and parenttype="Sales Order" and exists (select * from `tabSales Order` so where name = dnpi_in.parent and docstatus = 1 and status != 'Stopped') - ) dnpi) tab""", (d[0], d[1])) + ) dnpi) tab + where so_item_qty >= so_item_delivered_qty""", (d[0], d[1])) if flt(d[3]) != flt(reserved_qty[0][0]): print d[3], reserved_qty[0][0] From 26e5f3dec05aaa7aa0fc677902e9aad16ee66a1c Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Mon, 6 Aug 2012 18:20:08 +0530 Subject: [PATCH 03/23] DocType Mappers: Purchase Request-Supplier Quotation and Supplier Quotation-Purchase Order --- .../Purchase Request-Supplier Quotation.txt | 13 +- .../Supplier Quotation-Purchase Order.txt | 169 ++++++++++++++++++ 2 files changed, 171 insertions(+), 11 deletions(-) create mode 100644 erpnext/buying/DocType Mapper/Supplier Quotation-Purchase Order/Supplier Quotation-Purchase Order.txt diff --git a/erpnext/buying/DocType Mapper/Purchase Request-Supplier Quotation/Purchase Request-Supplier Quotation.txt b/erpnext/buying/DocType Mapper/Purchase Request-Supplier Quotation/Purchase Request-Supplier Quotation.txt index 95b13ba447..7d1de7524a 100644 --- a/erpnext/buying/DocType Mapper/Purchase Request-Supplier Quotation/Purchase Request-Supplier Quotation.txt +++ b/erpnext/buying/DocType Mapper/Purchase Request-Supplier Quotation/Purchase Request-Supplier Quotation.txt @@ -5,7 +5,7 @@ { 'creation': '2012-08-02 18:36:26', 'docstatus': 0, - 'modified': '2012-08-02 18:37:32', + 'modified': '2012-08-03 12:34:09', 'modified_by': u'Administrator', 'owner': u'Administrator' }, @@ -81,15 +81,6 @@ 'to_field': u'prevdoc_detail_docname' }, - # Field Mapper Detail - { - 'doctype': u'Field Mapper Detail', - 'from_field': u'uom', - 'map': u'Yes', - 'match_id': 1, - 'to_field': u'stock_uom' - }, - # Field Mapper Detail { 'checking_operator': u'>=', @@ -117,7 +108,7 @@ 'from_table': u'Purchase Request Item', 'match_id': 1, 'reference_doctype_key': u'prevdoc_doctype', - 'to_field': u'quotation_details', + 'to_field': u'quotation_items', 'to_table': u'Supplier Quotation Item', 'validation_logic': u'docstatus =1' } diff --git a/erpnext/buying/DocType Mapper/Supplier Quotation-Purchase Order/Supplier Quotation-Purchase Order.txt b/erpnext/buying/DocType Mapper/Supplier Quotation-Purchase Order/Supplier Quotation-Purchase Order.txt new file mode 100644 index 0000000000..a616266c91 --- /dev/null +++ b/erpnext/buying/DocType Mapper/Supplier Quotation-Purchase Order/Supplier Quotation-Purchase Order.txt @@ -0,0 +1,169 @@ +# DocType Mapper, Supplier Quotation-Purchase Order +[ + + # These values are common in all dictionaries + { + 'creation': '2012-08-03 12:33:04', + 'docstatus': 0, + 'modified': '2012-08-06 16:45:56', + 'modified_by': u'Administrator', + 'owner': u'Administrator' + }, + + # These values are common for all Table Mapper Detail + { + 'doctype': u'Table Mapper Detail', + 'name': '__common__', + 'parent': u'Supplier Quotation-Purchase Order', + 'parentfield': u'table_mapper_details', + 'parenttype': u'DocType Mapper', + 'validation_logic': u'docstatus = 1' + }, + + # These values are common for all Field Mapper Detail + { + 'doctype': u'Field Mapper Detail', + 'name': '__common__', + 'parent': u'Supplier Quotation-Purchase Order', + 'parentfield': u'field_mapper_details', + 'parenttype': u'DocType Mapper' + }, + + # These values are common for all DocType Mapper + { + 'doctype': u'DocType Mapper', + 'from_doctype': u'Supplier Quotation', + 'module': u'Buying', + 'name': '__common__', + 'ref_doc_submitted': 1, + 'to_doctype': u'Purchase Order' + }, + + # DocType Mapper, Supplier Quotation-Purchase Order + { + 'doctype': u'DocType Mapper', + 'name': u'Supplier Quotation-Purchase Order' + }, + + # Field Mapper Detail + { + 'checking_operator': u'=', + 'doctype': u'Field Mapper Detail', + 'from_field': u'company', + 'map': u'Yes', + 'match_id': 0, + 'to_field': u'company' + }, + + # Field Mapper Detail + { + 'checking_operator': u'>=', + 'doctype': u'Field Mapper Detail', + 'from_field': u'transaction_date', + 'map': u'No', + 'match_id': 0, + 'to_field': u'transaction_date' + }, + + # Field Mapper Detail + { + 'doctype': u'Field Mapper Detail', + 'from_field': u'conversion_rate', + 'map': u'Yes', + 'match_id': 0, + 'to_field': u'conversion_rate' + }, + + # Field Mapper Detail + { + 'doctype': u'Field Mapper Detail', + 'from_field': u'net_total', + 'map': u'Yes', + 'match_id': 0, + 'to_field': u'net_total' + }, + + # Field Mapper Detail + { + 'doctype': u'Field Mapper Detail', + 'from_field': u'total_tax', + 'map': u'Yes', + 'match_id': 0, + 'to_field': u'total_tax' + }, + + # Field Mapper Detail + { + 'doctype': u'Field Mapper Detail', + 'from_field': u'grand_total', + 'map': u'Yes', + 'match_id': 0, + 'to_field': u'grand_total' + }, + + # Field Mapper Detail + { + 'doctype': u'Field Mapper Detail', + 'from_field': u'parent', + 'map': u'Yes', + 'match_id': 1, + 'to_field': u'supplier_quotation' + }, + + # Field Mapper Detail + { + 'doctype': u'Field Mapper Detail', + 'from_field': u'name', + 'map': u'Yes', + 'match_id': 1, + 'to_field': u'supplier_quotation_item' + }, + + # Field Mapper Detail + { + 'doctype': u'Field Mapper Detail', + 'from_field': u'uom', + 'map': u'Yes', + 'match_id': 1, + 'to_field': u'stock_uom' + }, + + # Field Mapper Detail + { + 'doctype': u'Field Mapper Detail', + 'from_field': u'eval:flt(1)', + 'map': u'Yes', + 'match_id': 1, + 'to_field': u'conversion_factor' + }, + + # Table Mapper Detail + { + 'doctype': u'Table Mapper Detail', + 'from_table': u'Supplier Quotation', + 'match_id': 0, + 'reference_key': u'prevdoc_docname', + 'to_table': u'Purchase Order' + }, + + # Table Mapper Detail + { + 'doctype': u'Table Mapper Detail', + 'from_field': u'quotation_details', + 'from_table': u'Supplier Quotation Item', + 'match_id': 1, + 'reference_doctype_key': u'prevdoc_doctype', + 'to_field': u'po_details', + 'to_table': u'Purchase Order Item' + }, + + # Table Mapper Detail + { + 'doctype': u'Table Mapper Detail', + 'from_field': u'purchase_tax_details', + 'from_table': u'Purchase Taxes and Charges', + 'match_id': 2, + 'to_field': u'purchase_tax_details', + 'to_table': u'Purchase Taxes and Charges' + } +] \ No newline at end of file From 41c4d19279d20b141f725dda89e45c57b6c8374b Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Mon, 6 Aug 2012 18:22:59 +0530 Subject: [PATCH 04/23] added button to make Purchase Order from Supplier Quotation --- .../supplier_quotation/supplier_quotation.js | 23 ++++++++++++------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/erpnext/buying/doctype/supplier_quotation/supplier_quotation.js b/erpnext/buying/doctype/supplier_quotation/supplier_quotation.js index 4d2673c5ef..430d1eed99 100644 --- a/erpnext/buying/doctype/supplier_quotation/supplier_quotation.js +++ b/erpnext/buying/doctype/supplier_quotation/supplier_quotation.js @@ -47,13 +47,17 @@ cur_frm.cscript.refresh = function(doc, dt, dn) { } } -cur_frm.cscript.toggle_contact_section = function(doc) { - console.log(doc.supplier); - doc.supplier ? unhide_field("contact_section") : hide_field("contact_section"); -} - -cur_frm.cscript.make_purchase_order = function(doc, dt, dn) { - +cur_frm.cscript.make_purchase_order = function() { + var new_po_name = createLocal("Purchase Order"); + $c("dt_map", { + "docs": compress_doclist([locals['Purchase Order'][new_po_name]]), + "from_doctype": cur_frm.doc.doctype, + "to_doctype": "Purchase Order", + "from_docname": cur_frm.doc.name, + "from_to_list": JSON.stringify([['Supplier Quotation', 'Purchase Order'], + ['Supplier Quotation Item', 'Purchase Order Item'], + ['Purchase Taxes and Charges', 'Purchase Taxes and Charges']]), + }, function(r, rt) { loaddoc("Purchase Order", new_po_name) }); } cur_frm.cscript.supplier = function(doc, dt, dn) { @@ -65,6 +69,10 @@ cur_frm.cscript.supplier = function(doc, dt, dn) { } } +cur_frm.cscript.uom = function(doc, cdt, cdn) { + // no need to trigger updation of stock uom, as this field doesn't exist in supplier quotation +} + cur_frm.fields_dict['quotation_items'].grid.get_field('project_name').get_query = function(doc, cdt, cdn) { return "select `tabProject`.name from `tabProject` \ @@ -82,7 +90,6 @@ cur_frm.fields_dict['indent_no'].get_query = function(doc) { order by `tabPurchase Request`.`name` desc limit 50"; } - cur_frm.cscript.supplier_address = function(doc, dt, dn) { if (doc.supplier) { get_server_fields("get_supplier_address", JSON.stringify({supplier: doc.supplier, From 280e0ce263fe2402cdd733cbb3ee8c90f520b12c Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Mon, 6 Aug 2012 18:23:45 +0530 Subject: [PATCH 05/23] added function to hide/unhide contact section of a buying form --- erpnext/buying/doctype/purchase_common/purchase_common.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/erpnext/buying/doctype/purchase_common/purchase_common.js b/erpnext/buying/doctype/purchase_common/purchase_common.js index 81d5fbf813..68dc8c73d4 100644 --- a/erpnext/buying/doctype/purchase_common/purchase_common.js +++ b/erpnext/buying/doctype/purchase_common/purchase_common.js @@ -122,7 +122,6 @@ var set_dynamic_label_child = function(doc, cdt, cdn, base_curr) { cur_frm.cscript.dynamic_label = function(doc, cdt, cdn, callback1) { var base_currency = wn.boot.company[doc.company].default_currency || sys_defaults['currency']; - if (doc.currency === base_currency) { set_multiple(cdt, cdn, {conversion_rate:1}); hide_field(['conversion_rate', 'net_total_import','grand_total_import', @@ -634,3 +633,7 @@ cur_frm.cscript.check_charge_type_and_get_tax_amount = function(doc, tax, t, cl, } } } + +cur_frm.cscript.toggle_contact_section = function(doc) { + doc.supplier ? unhide_field("contact_section") : hide_field("contact_section"); +} \ No newline at end of file From da85a8363fe6fc913fc2676d09e56ec392604250 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Mon, 6 Aug 2012 18:24:56 +0530 Subject: [PATCH 06/23] call set missing values on load and contact section toggle on refresh of purchase order form --- .../doctype/purchase_order/purchase_order.js | 21 +++++++++---------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/erpnext/buying/doctype/purchase_order/purchase_order.js b/erpnext/buying/doctype/purchase_order/purchase_order.js index a27f6ff73b..a1983c34a7 100644 --- a/erpnext/buying/doctype/purchase_order/purchase_order.js +++ b/erpnext/buying/doctype/purchase_order/purchase_order.js @@ -24,15 +24,15 @@ wn.require('erpnext/utilities/doctype/sms_control/sms_control.js'); wn.require('erpnext/setup/doctype/notification_control/notification_control.js'); cur_frm.cscript.onload = function(doc, cdt, cdn) { - - if(!doc.fiscal_year && doc.__islocal){ //set_default_values(doc); - doc.fiscal_year = sys_defaults.fiscal_year; - } - if(!doc.conversion_rate) doc.conversion_rate = 1; - if(!doc.currency) doc.currency = sys_defaults.currency; - if(!doc.status) set_multiple(cdt,cdn,{status:'Draft'}); - if(!doc.transaction_date) set_multiple(cdt,cdn,{transaction_date:get_today()}); - if(!doc.is_subcontracted) set_multiple(cdt, cdn, {is_subcontracted:'No'}); + // set missing values in parent doc + set_missing_values(doc, { + fiscal_year: sys_defaults.fiscal_year, + conversion_rate: 1, + currency: sys_defaults.currency, + status: "Draft", + transaction_date: get_today(), + is_subcontracted: "No" + }); } cur_frm.cscript.onload_post_render = function(doc, dt, dn) { @@ -55,8 +55,7 @@ cur_frm.cscript.refresh = function(doc, cdt, cdn) { if(doc.docstatus == 1 && doc.status == 'Stopped') cur_frm.add_custom_button('Unstop Purchase Order', cur_frm.cscript['Unstop Purchase Order']); - if(doc.supplier) $(cur_frm.fields_dict.contact_section.row.wrapper).toggle(true); - else $(cur_frm.fields_dict.contact_section.row.wrapper).toggle(false); + cur_frm.cscript.toggle_contact_section(doc); } cur_frm.cscript.supplier = function(doc,dt,dn) { From b6029d2d135b30aae2c29c890955fa12c3972c82 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Mon, 6 Aug 2012 18:26:07 +0530 Subject: [PATCH 07/23] added button, method in Purchase Order to fetch Supplier Quotation Items --- .../doctype/purchase_order/purchase_order.py | 15 ++++++++- .../doctype/purchase_order/purchase_order.txt | 33 +++++++++++++++++-- 2 files changed, 44 insertions(+), 4 deletions(-) diff --git a/erpnext/buying/doctype/purchase_order/purchase_order.py b/erpnext/buying/doctype/purchase_order/purchase_order.py index 40b7281f84..d84d06eda9 100644 --- a/erpnext/buying/doctype/purchase_order/purchase_order.py +++ b/erpnext/buying/doctype/purchase_order/purchase_order.py @@ -86,7 +86,7 @@ class DocType(TransactionBase): if self.doc.indent_no: get_obj('DocType Mapper','Purchase Request-Purchase Order').dt_map('Purchase Request','Purchase Order',self.doc.indent_no, self.doc, self.doclist, "[['Purchase Request','Purchase Order'],['Purchase Request Item', 'Purchase Order Item']]") pcomm = get_obj('Purchase Common') - for d in getlist(self.doclist, 'po_details'): + for d in getlist(self.doclist, 'po_details'): if d.item_code and not d.purchase_rate: last_purchase_details, last_purchase_date = pcomm.get_last_purchase_details(d.item_code, self.doc.name) if last_purchase_details: @@ -99,6 +99,19 @@ class DocType(TransactionBase): d.import_rate = d.purchase_rate / conversion_rate else: d.purchase_ref_rate = d.discount_rate = d.purchase_rate = d.import_ref_rate = d.import_rate = 0.0 + + def get_supplier_quotation_items(self): + if self.doc.supplier_quotation: + get_obj("DocType Mapper", "Supplier Quotation-Purchase Order").dt_map("Supplier Quotation", + "Purchase Order", self.doc.supplier_quotation, self.doc, self.doclist, + """[['Supplier Quotation', 'Purchase Order'], + ['Supplier Quotation Item', 'Purchase Order Item'], + ['Purchase Taxes and Charges', 'Purchase Taxes and Charges']]""") + self.get_default_schedule_date() + for d in getlist(self.doclist, 'po_details'): + if d.prevdoc_detail_docname and not d.schedule_date: + d.schedule_date = webnotes.conn.get_value("Purchase Request Item", + d.prevdoc_detail_docname, "schedule_date") def get_tc_details(self): """get terms & conditions""" diff --git a/erpnext/buying/doctype/purchase_order/purchase_order.txt b/erpnext/buying/doctype/purchase_order/purchase_order.txt index 318ebda35b..d5e8df51c5 100644 --- a/erpnext/buying/doctype/purchase_order/purchase_order.txt +++ b/erpnext/buying/doctype/purchase_order/purchase_order.txt @@ -5,7 +5,7 @@ { 'creation': '2012-07-02 14:44:19', 'docstatus': 0, - 'modified': '2012-08-02 13:43:50', + 'modified': '2012-08-06 17:14:19', 'modified_by': u'Administrator', 'owner': u'Administrator' }, @@ -464,9 +464,35 @@ 'fieldtype': u'Button', 'hidden': 0, 'label': u'Get Items', + 'no_copy': 0, 'oldfieldtype': u'Button', 'options': u'get_indent_details', - 'permlevel': 0 + 'permlevel': 0, + 'print_hide': 1 + }, + + # DocField + { + 'description': u'You can make a purchase order from multiple Supplier Quotations. Select Supplier Quotations one by one and click on the button below.', + 'doctype': u'DocField', + 'fieldname': u'supplier_quotation', + 'fieldtype': u'Link', + 'label': u'Select Supplier Quotation', + 'no_copy': 1, + 'options': u'Supplier Quotation', + 'permlevel': 0, + 'print_hide': 1 + }, + + # DocField + { + 'doctype': u'DocField', + 'fieldname': u'get_supplier_quotation_items', + 'fieldtype': u'Button', + 'label': u'Get Items', + 'options': u'get_supplier_quotation_items', + 'permlevel': 0, + 'print_hide': 1 }, # DocField @@ -477,7 +503,8 @@ 'fieldtype': u'Section Break', 'label': u'Taxes', 'oldfieldtype': u'Section Break', - 'permlevel': 0 + 'permlevel': 0, + 'print_hide': 0 }, # DocField From 72f5a05ac008e5b18e499b506db850d186fa684e Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Mon, 6 Aug 2012 18:27:11 +0530 Subject: [PATCH 08/23] added fields 'Supplier Quotation' and 'Supplier Quotation Item' in Purchase Order Item to track parent --- .../purchase_order_item.txt | 30 +++++++++++++++++-- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/erpnext/buying/doctype/purchase_order_item/purchase_order_item.txt b/erpnext/buying/doctype/purchase_order_item/purchase_order_item.txt index 73a6f0165f..cecf9630c7 100755 --- a/erpnext/buying/doctype/purchase_order_item/purchase_order_item.txt +++ b/erpnext/buying/doctype/purchase_order_item/purchase_order_item.txt @@ -5,7 +5,7 @@ { 'creation': '2012-05-15 12:14:38', 'docstatus': 0, - 'modified': '2012-06-29 13:05:33', + 'modified': '2012-08-06 15:55:11', 'modified_by': u'Administrator', 'owner': u'Administrator' }, @@ -335,7 +335,7 @@ 'fieldtype': u'Date', 'hidden': 1, 'in_filter': 1, - 'label': u'Purchase Requisition Date', + 'label': u'Purchase Request Date', 'oldfieldname': u'prevdoc_date', 'oldfieldtype': u'Date', 'permlevel': 1, @@ -351,7 +351,7 @@ 'fieldtype': u'Data', 'hidden': 1, 'in_filter': 1, - 'label': u'Purchase Requisition Detail No', + 'label': u'Purchase Request Detail No', 'no_copy': 0, 'oldfieldname': u'prevdoc_detail_docname', 'oldfieldtype': u'Data', @@ -360,6 +360,30 @@ 'search_index': 1 }, + # DocField + { + 'doctype': u'DocField', + 'fieldname': u'supplier_quotation', + 'fieldtype': u'Link', + 'hidden': 1, + 'in_filter': 0, + 'label': u'Supplier Quotation', + 'options': u'Supplier Quotation', + 'permlevel': 1, + 'search_index': 0 + }, + + # DocField + { + 'doctype': u'DocField', + 'fieldname': u'supplier_quotation_item', + 'fieldtype': u'Link', + 'hidden': 1, + 'label': u'Supplier Quotation Item', + 'options': u'Supplier Quotation Item', + 'permlevel': 1 + }, + # DocField { 'doctype': u'DocField', From 6ea82c07fe560bf9fc1b2988e26f946faaa4f856 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Mon, 6 Aug 2012 18:27:58 +0530 Subject: [PATCH 09/23] added button, method in Purchase Request form to make Supplier Quotation --- .../purchase_request/purchase_request.js | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/erpnext/buying/doctype/purchase_request/purchase_request.js b/erpnext/buying/doctype/purchase_request/purchase_request.js index c29434dee2..733da5260c 100644 --- a/erpnext/buying/doctype/purchase_request/purchase_request.js +++ b/erpnext/buying/doctype/purchase_request/purchase_request.js @@ -51,10 +51,11 @@ cur_frm.cscript.refresh = function(doc, cdt, cdn) { if(doc.docstatus == 1 && doc.status != 'Stopped'){ if(doc.per_ordered < 100) { - cur_frm.add_custom_button('Make Purchase Order', cur_frm.cscript['Make Purchase Order']) - cur_frm.add_custom_button('Stop Purchase Request', cur_frm.cscript['Stop Purchase Request']) + cur_frm.add_custom_button('Make Purchase Order', cur_frm.cscript['Make Purchase Order']); + cur_frm.add_custom_button('Stop Purchase Request', cur_frm.cscript['Stop Purchase Request']); } cur_frm.add_custom_button('Send SMS', cur_frm.cscript.send_sms); + cur_frm.add_custom_button("Make Supplier Quotation", cur_frm.cscript.make_supplier_quotation); } if(doc.docstatus == 1 && doc.status == 'Stopped') @@ -124,3 +125,15 @@ cur_frm.cscript['Unstop Purchase Request'] = function(){ }); } } + +cur_frm.cscript.make_supplier_quotation = function() { + var new_sq_name = createLocal("Supplier Quotation"); + $c("dt_map", { + "docs": compress_doclist([locals['Supplier Quotation'][new_sq_name]]), + "from_doctype": cur_frm.doc.doctype, + "to_doctype": "Supplier Quotation", + "from_docname": cur_frm.doc.name, + "from_to_list": JSON.stringify([['Purchase Request', 'Supplier Quotation'], + ['Purchase Request Item', 'Supplier Quotation Item']]), + }, function(r, rt) { loaddoc("Supplier Quotation", new_sq_name) }); +} \ No newline at end of file From 793ec9f857218e6cbba049cbe9fb9a8380038cab Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Mon, 6 Aug 2012 18:29:03 +0530 Subject: [PATCH 10/23] removed method get_uom_details from Supplier Quotation, as there is no need to track Stock UOM in a quotation --- .../doctype/supplier_quotation/supplier_quotation.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/erpnext/buying/doctype/supplier_quotation/supplier_quotation.py b/erpnext/buying/doctype/supplier_quotation/supplier_quotation.py index f52e428744..f5b9335c4d 100644 --- a/erpnext/buying/doctype/supplier_quotation/supplier_quotation.py +++ b/erpnext/buying/doctype/supplier_quotation/supplier_quotation.py @@ -21,7 +21,7 @@ from utilities.transaction_base import TransactionBase class DocType(TransactionBase): def __init__(self, doc, doclist=None): self.doc, self.doclist = doc, doclist or [] - self.tname, self.fname = "Supplier Quotation Item", "quotation_item" + self.tname, self.fname = "Supplier Quotation Item", "quotation_items" def autoname(self): """autoname based on naming series value""" @@ -66,7 +66,8 @@ class DocType(TransactionBase): self.doc, self.doclist, """[['Purchase Request', 'Supplier Quotation'], ['Purchase Request Item', 'Supplier Quotation Item']]""") - for d in getlist(self.doclist, "quotation_details"): + from webnotes.model.doclist import getlist + for d in getlist(self.doclist, self.fname): if d.item_code and not d.purchase_rate: d.purchase_ref_rate = d.discount_rate = d.purchase_rate = 0.0 d.import_ref_rate = d.import_rate = 0.0 @@ -74,9 +75,6 @@ class DocType(TransactionBase): def get_purchase_tax_details(self): self.doclist = get_obj('Purchase Common').get_purchase_tax_details(self) - def get_uom_details(self, args=None): - return get_obj('Purchase Common').get_uom_details(args) - def validate_fiscal_year(self): get_obj(dt = 'Purchase Common').validate_fiscal_year( \ self.doc.fiscal_year, self.doc.transaction_date, 'Quotation Date') From 3e92c00dd9e3ec5f0a190240edc5d253f9b203c6 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Mon, 6 Aug 2012 18:29:46 +0530 Subject: [PATCH 11/23] removed stock uom related fields from supplier quotation item, as there is no need to track stock uom details in a suppleir quoation --- .../supplier_quotation_item.txt | 34 +------------------ 1 file changed, 1 insertion(+), 33 deletions(-) diff --git a/erpnext/buying/doctype/supplier_quotation_item/supplier_quotation_item.txt b/erpnext/buying/doctype/supplier_quotation_item/supplier_quotation_item.txt index 1ee10ae496..895c8fc899 100644 --- a/erpnext/buying/doctype/supplier_quotation_item/supplier_quotation_item.txt +++ b/erpnext/buying/doctype/supplier_quotation_item/supplier_quotation_item.txt @@ -5,7 +5,7 @@ { 'creation': '2012-08-01 20:07:22', 'docstatus': 0, - 'modified': '2012-08-02 16:00:52', + 'modified': '2012-08-03 12:34:33', 'modified_by': u'Administrator', 'owner': u'Administrator' }, @@ -241,38 +241,6 @@ 'width': u'100px' }, - # DocField - { - 'colour': u'White:FFF', - 'doctype': u'DocField', - 'fieldname': u'conversion_factor', - 'fieldtype': u'Currency', - 'hidden': 0, - 'label': u'UOM Conversion Factor', - 'oldfieldname': u'conversion_factor', - 'oldfieldtype': u'Currency', - 'permlevel': 0, - 'print_hide': 1, - 'reqd': 1, - 'trigger': u'Client', - 'width': u'100px' - }, - - # DocField - { - 'doctype': u'DocField', - 'fieldname': u'stock_uom', - 'fieldtype': u'Data', - 'hidden': 0, - 'label': u'Stock UOM', - 'oldfieldname': u'stock_uom', - 'oldfieldtype': u'Data', - 'permlevel': 1, - 'print_hide': 1, - 'reqd': 1, - 'width': u'100px' - }, - # DocField { 'colour': u'White:FFF', From 8ce2ac3f0e69b8968d4f88eaa72d04908661dfa8 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Mon, 6 Aug 2012 19:53:31 +0530 Subject: [PATCH 12/23] supplier quotation release patch --- erpnext/patches/july_2012/supplier_quotation.py | 14 ++++++++++++++ erpnext/patches/patch_list.py | 4 ++++ 2 files changed, 18 insertions(+) create mode 100644 erpnext/patches/july_2012/supplier_quotation.py diff --git a/erpnext/patches/july_2012/supplier_quotation.py b/erpnext/patches/july_2012/supplier_quotation.py new file mode 100644 index 0000000000..023ead2ca6 --- /dev/null +++ b/erpnext/patches/july_2012/supplier_quotation.py @@ -0,0 +1,14 @@ +def execute(): + """sync supplier quotatoin and create supplier quotation mappers""" + from webnotes.model.sync import sync + sync('buying', 'supplier_quotation') + sync('buying', 'supplier_quotation_item') + sync('buying', 'purchase_request') + sync('buying', 'purchase_request_item') + sync('buying', 'purchase_order') + sync('buying', 'purchase_order_item') + + from webnotes.modules import reload_doc + reload_doc('buying', 'DocType Mapper', 'Purchase Request-Supplier Quotation') + reload_doc('buying', 'DocType Mapper', 'Supplier Quotation-Purchase Order') + \ No newline at end of file diff --git a/erpnext/patches/patch_list.py b/erpnext/patches/patch_list.py index eace14c368..f512bfc0e3 100644 --- a/erpnext/patches/patch_list.py +++ b/erpnext/patches/patch_list.py @@ -513,4 +513,8 @@ patch_list = [ 'patch_module': 'patches.july_2012', 'patch_file': 'repost_stock_due_to_wrong_packing_list', }, + { + 'patch_module': 'patches.july_2012', + 'patch_file': 'supplier_quotation', + }, ] \ No newline at end of file From a742d32c96ba577fd77f7986e1537521d1aae82d Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Mon, 6 Aug 2012 20:03:49 +0530 Subject: [PATCH 13/23] added unicode literals import to supplier quotation patch --- erpnext/patches/july_2012/supplier_quotation.py | 1 + 1 file changed, 1 insertion(+) diff --git a/erpnext/patches/july_2012/supplier_quotation.py b/erpnext/patches/july_2012/supplier_quotation.py index 023ead2ca6..84809e52ba 100644 --- a/erpnext/patches/july_2012/supplier_quotation.py +++ b/erpnext/patches/july_2012/supplier_quotation.py @@ -1,3 +1,4 @@ +from __future__ import unicode_literals def execute(): """sync supplier quotatoin and create supplier quotation mappers""" from webnotes.model.sync import sync From e343393d7324875ad2f63e533d4f7262989f9563 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Tue, 7 Aug 2012 10:53:52 +0530 Subject: [PATCH 14/23] add/drop index if index key not exists / exists --- erpnext/stock/doctype/item/item.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/stock/doctype/item/item.txt b/erpnext/stock/doctype/item/item.txt index 06806bac04..d87f56d2f9 100644 --- a/erpnext/stock/doctype/item/item.txt +++ b/erpnext/stock/doctype/item/item.txt @@ -5,7 +5,7 @@ { 'creation': '2012-06-08 12:54:51', 'docstatus': 0, - 'modified': '2012-07-04 11:10:29', + 'modified': '2012-07-04 11:10:51', 'modified_by': u'Administrator', 'owner': u'Administrator' }, From c7dbe293c3926741cd8f9e4d9dda9e204920e18e Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Tue, 7 Aug 2012 12:12:55 +0530 Subject: [PATCH 15/23] updates to kb: unanswered questions show in desktop, questions query moved to server-side --- erpnext/home/page/desktop/desktop.js | 1 + erpnext/startup/startup.js | 1 + erpnext/startup/startup.py | 25 ++++++------- erpnext/utilities/page/kb_common/kb_common.js | 13 +++++++ .../utilities/page/questions/questions.css | 4 ++ erpnext/utilities/page/questions/questions.js | 32 +++++++--------- erpnext/utilities/page/questions/questions.py | 37 ++++++++++++------- public/js/all-app.js | 2 +- public/js/all-web.js | 2 +- public/js/kb_common.js | 4 +- 10 files changed, 73 insertions(+), 48 deletions(-) diff --git a/erpnext/home/page/desktop/desktop.js b/erpnext/home/page/desktop/desktop.js index 0db20fb0c6..9ba5253e41 100644 --- a/erpnext/home/page/desktop/desktop.js +++ b/erpnext/home/page/desktop/desktop.js @@ -126,6 +126,7 @@ erpnext.desktop.show_pending_notifications = function() { add_circle('todo', 'things_todo', 'Things To Do'); add_circle('calendar', 'todays_events', 'Todays Events'); add_circle('project', 'open_tasks', 'Open Tasks'); + add_circle('kb', 'unanswered_questions', 'Unanswered Questions'); erpnext.update_messages(); diff --git a/erpnext/startup/startup.js b/erpnext/startup/startup.js index 9ea3c8959a..60104645b0 100644 --- a/erpnext/startup/startup.js +++ b/erpnext/startup/startup.js @@ -136,6 +136,7 @@ erpnext.update_messages = function(reset) { show_in_circle('things_todo', r.message.things_todo); show_in_circle('todays_events', r.message.todays_events); show_in_circle('open_tasks', r.message.open_tasks); + show_in_circle('unanswered_questions', r.message.unanswered_questions); } else { clearInterval(wn.updates.id); diff --git a/erpnext/startup/startup.py b/erpnext/startup/startup.py index f21f2519fe..0ae31141fe 100644 --- a/erpnext/startup/startup.py +++ b/erpnext/startup/startup.py @@ -1,3 +1,4 @@ +from __future__ import unicode_literals import webnotes def get_unread_messages(): @@ -11,9 +12,7 @@ def get_unread_messages(): """, webnotes.user.name, as_list=1) def get_open_support_tickets(): - """ - Returns a count of open support tickets - """ + """Returns a count of open support tickets""" from webnotes.utils import cint open_support_tickets = webnotes.conn.sql("""\ SELECT COUNT(*) FROM `tabSupport Ticket` @@ -21,18 +20,14 @@ def get_open_support_tickets(): return open_support_tickets and cint(open_support_tickets[0][0]) or 0 def get_open_tasks(): - """ - Returns a count of open tasks - """ + """Returns a count of open tasks""" from webnotes.utils import cint return webnotes.conn.sql("""\ SELECT COUNT(*) FROM `tabTask` WHERE status = 'Open'""")[0][0] def get_things_todo(): - """ - Returns a count of incomplete todos - """ + """Returns a count of incomplete todos""" from webnotes.utils import cint incomplete_todos = webnotes.conn.sql("""\ SELECT COUNT(*) FROM `tabToDo` @@ -41,9 +36,7 @@ def get_things_todo(): return incomplete_todos and cint(incomplete_todos[0][0]) or 0 def get_todays_events(): - """ - Returns a count of todays events in calendar - """ + """Returns a count of todays events in calendar""" from webnotes.utils import nowdate, cint todays_events = webnotes.conn.sql("""\ SELECT COUNT(*) FROM `tabEvent` @@ -53,6 +46,11 @@ def get_todays_events(): webnotes.session.get('user'), nowdate())) return todays_events and cint(todays_events[0][0]) or 0 +def get_unanswered_questions(): + return len(filter(lambda d: d[0]==0, + webnotes.conn.sql("""select (select count(*) from tabAnswer + where tabAnswer.question = tabQuestion.name) as answers from tabQuestion"""))) + @webnotes.whitelist() def get_global_status_messages(arg=None): return { @@ -60,5 +58,6 @@ def get_global_status_messages(arg=None): 'open_support_tickets': get_open_support_tickets(), 'things_todo': get_things_todo(), 'todays_events': get_todays_events(), - 'open_tasks': get_open_tasks() + 'open_tasks': get_open_tasks(), + 'unanswered_questions': get_unanswered_questions() } diff --git a/erpnext/utilities/page/kb_common/kb_common.js b/erpnext/utilities/page/kb_common/kb_common.js index d77a938e0e..a135612d7e 100644 --- a/erpnext/utilities/page/kb_common/kb_common.js +++ b/erpnext/utilities/page/kb_common/kb_common.js @@ -25,6 +25,7 @@ KBItemToolbar = function(args, kb) { this.wrapper = $a(this.parent, 'div', '', {}); this.line1 = $a(this.wrapper, 'div', '', {color: '#888', fontSize:'11px', margin:'7px 0px'}); this.make_timestamp(); + this.make_answers(); if(this.with_tags) this.make_tags(); this.setup_del(); @@ -43,6 +44,18 @@ KBItemToolbar = function(args, kb) { } } + this.make_answers = function() { + if(this.doctype=='Question') { + if(this.det.answers==0) { + this.line1.innerHTML += ' | no answers'; + } else if(this.det.answers==1) { + this.line1.innerHTML += ' | 1 answer'; + } else { + this.line1.innerHTML += ' | '+this.det.answers+' answers'; + } + } + } + this.make_tags = function() { this.line1.innerHTML += ' | ' this.tags_area = $a(this.line1, 'span', 'kb-tags') diff --git a/erpnext/utilities/page/questions/questions.css b/erpnext/utilities/page/questions/questions.css index 52e8a38f2e..779da5505e 100644 --- a/erpnext/utilities/page/questions/questions.css +++ b/erpnext/utilities/page/questions/questions.css @@ -14,6 +14,10 @@ div.kb-search-wrapper textarea { .kb-questions { } +.un-answered { + color: #f33; +} + .kb-question-details { margin: 11px 0px 11px 29px; } diff --git a/erpnext/utilities/page/questions/questions.js b/erpnext/utilities/page/questions/questions.js index 048ed54bb6..22a70d8f41 100644 --- a/erpnext/utilities/page/questions/questions.js +++ b/erpnext/utilities/page/questions/questions.js @@ -115,24 +115,16 @@ function KnowledgeBase(w) { no_results_message: 'No questions found. Ask a new question!', appframe: wn.pages.questions.appframe, as_dict: 1, - get_query: function() { - - // filter by search string - var v = me.search.value==$(me.search).attr('default_text') ? '' : me.search.value; - cond = v ? (' and t1.question like "%'+v+'%"') : ''; - - // filter by tags - if(me.tag_filter_dict) { - for(f in me.tag_filter_dict) { - cond += ' and t1.`_user_tags` like "%' + f + '%"' - } + method: 'utilities.page.questions.questions.get_questions', + get_args: function() { + var args = {}; + if(me.search.value) { + args.search_text = me.search.value; } - return repl('select t1.name, t1.owner, t1.question, t1.modified, t1._user_tags, ' - +'t1._users_voted, t2.first_name, t2.last_name ' - +'from tabQuestion t1, tabProfile t2 ' - +'where t1.docstatus!=2 ' - +'and t1.owner = t2.name' - +'%(cond)s order by t1.modified desc', {user:user, cond: cond}) + if(me.tag_filter_dict) { + args.tag_filters = keys(me.tag_filter_dict); + } + return args }, render_row: function(parent, data, listing) { new KBQuestion(parent, data, me); @@ -196,7 +188,11 @@ KBQuestion = function(parent, det, kb) { this.make = function() { this.wrapper = $a(parent, 'div', 'kb-question-wrapper'); - this.q_area = $a($a(this.wrapper, 'div'), 'h3', 'kb-questions link_type', {display:'inline', textDecoration:'none'}, det.question); + this.q_area = $a($a(this.wrapper, 'div'), 'h3', + 'kb-questions link_type', {display:'inline', textDecoration:'none'}, det.question); + if(det.answers==0) { + $(this.q_area).addClass('un-answered') + } this.q_area.onclick = function() { var q = this; diff --git a/erpnext/utilities/page/questions/questions.py b/erpnext/utilities/page/questions/questions.py index 52b80fe280..bd9efc7385 100644 --- a/erpnext/utilities/page/questions/questions.py +++ b/erpnext/utilities/page/questions/questions.py @@ -19,6 +19,29 @@ import webnotes from webnotes.utils import load_json, cint, cstr import json +@webnotes.whitelist() +def get_questions(): + """get list of questions""" + import json + conds = '' + + if 'search_text' in webnotes.form_dict: + conds = ' and t1.question like "%'+ webnotes.form_dict['search_text'] + '%"' + + if 'tag_filters' in webnotes.form_dict: + tag_filters = json.loads(webnotes.form_dict['tag_filters']) + for t in tag_filters: + conds += ' and t1._user_tags like "%'+ t +'%"' + + return webnotes.conn.sql("""select t1.name, t1.owner, t1.question, t1.modified, t1._user_tags, + t2.first_name, t2.last_name, (select count(*) from tabAnswer where + tabAnswer.question = t1.name) as answers + from tabQuestion t1, tabProfile t2 + where t1.docstatus!=2 + and t1.owner = t2.name + %(conds)s + order by t1.modified desc""" % {"conds":conds}, as_dict=1) + # add a new question @webnotes.whitelist() def add_question(arg): @@ -39,20 +62,6 @@ def add_question(arg): 'txt': 'Please help me and answer the question "%s" in the Knowledge Base' % d.question, 'notify': 1 })) - -@webnotes.whitelist() -def vote(arg): - args = load_json(arg) - - res = webnotes.conn.sql("select points, _users_voted from `tab%s` where name=%s" % (args['dt'], '%s'), args['dn'])[0] - p = cint(res[0]) - p = args['vote']=='up' and p+1 or p-1 - - # update - webnotes.conn.sql("update `tab%s` set points=%s, _users_voted=%s where name=%s" % (args['dt'], '%s', '%s', '%s'), \ - (p, cstr(res[1]) + ',' + webnotes.user.name, args['dn'])) - - return p @webnotes.whitelist() def delete(arg): diff --git a/public/js/all-app.js b/public/js/all-app.js index 3c50ed2ebd..6d6c820aa4 100644 --- a/public/js/all-app.js +++ b/public/js/all-app.js @@ -2258,7 +2258,7 @@ $('body').append('')} erpnext.update_messages=function(reset){if(inList(['Guest'],user)||!wn.session_alive){return;} if(!reset){var set_messages=function(r){if(!r.exc){erpnext.toolbar.set_new_comments(r.message.unread_messages);var show_in_circle=function(parent_id,msg){var parent=$('#'+parent_id);if(parent){if(msg){parent.find('span:first').text(msg);parent.toggle(true);}else{parent.toggle(false);}}} -show_in_circle('unread_messages',r.message.unread_messages.length);show_in_circle('open_support_tickets',r.message.open_support_tickets);show_in_circle('things_todo',r.message.things_todo);show_in_circle('todays_events',r.message.todays_events);show_in_circle('open_tasks',r.message.open_tasks);}else{clearInterval(wn.updates.id);}} +show_in_circle('unread_messages',r.message.unread_messages.length);show_in_circle('open_support_tickets',r.message.open_support_tickets);show_in_circle('things_todo',r.message.things_todo);show_in_circle('todays_events',r.message.todays_events);show_in_circle('open_tasks',r.message.open_tasks);show_in_circle('unanswered_questions',r.message.unanswered_questions);}else{clearInterval(wn.updates.id);}} wn.call({method:'startup.startup.get_global_status_messages',callback:set_messages});}else{erpnext.toolbar.set_new_comments(0);$('#unread_messages').toggle(false);}} erpnext.startup.set_periodic_updates=function(){wn.updates={};if(wn.updates.id){clearInterval(wn.updates.id);} wn.updates.id=setInterval(erpnext.update_messages,60000);} diff --git a/public/js/all-web.js b/public/js/all-web.js index c52a51ad3f..44860f4a37 100644 --- a/public/js/all-web.js +++ b/public/js/all-web.js @@ -726,7 +726,7 @@ $('body').append('')} erpnext.update_messages=function(reset){if(inList(['Guest'],user)||!wn.session_alive){return;} if(!reset){var set_messages=function(r){if(!r.exc){erpnext.toolbar.set_new_comments(r.message.unread_messages);var show_in_circle=function(parent_id,msg){var parent=$('#'+parent_id);if(parent){if(msg){parent.find('span:first').text(msg);parent.toggle(true);}else{parent.toggle(false);}}} -show_in_circle('unread_messages',r.message.unread_messages.length);show_in_circle('open_support_tickets',r.message.open_support_tickets);show_in_circle('things_todo',r.message.things_todo);show_in_circle('todays_events',r.message.todays_events);show_in_circle('open_tasks',r.message.open_tasks);}else{clearInterval(wn.updates.id);}} +show_in_circle('unread_messages',r.message.unread_messages.length);show_in_circle('open_support_tickets',r.message.open_support_tickets);show_in_circle('things_todo',r.message.things_todo);show_in_circle('todays_events',r.message.todays_events);show_in_circle('open_tasks',r.message.open_tasks);show_in_circle('unanswered_questions',r.message.unanswered_questions);}else{clearInterval(wn.updates.id);}} wn.call({method:'startup.startup.get_global_status_messages',callback:set_messages});}else{erpnext.toolbar.set_new_comments(0);$('#unread_messages').toggle(false);}} erpnext.startup.set_periodic_updates=function(){wn.updates={};if(wn.updates.id){clearInterval(wn.updates.id);} wn.updates.id=setInterval(erpnext.update_messages,60000);} diff --git a/public/js/kb_common.js b/public/js/kb_common.js index e61b5ef91b..d478cac368 100644 --- a/public/js/kb_common.js +++ b/public/js/kb_common.js @@ -2,10 +2,12 @@ /* * erpnext/utilities/page/kb_common/kb_common.js */ -KBItemToolbar=function(args,kb){$.extend(this,args);var me=this;this.make=function(){this.wrapper=$a(this.parent,'div','',{});this.line1=$a(this.wrapper,'div','',{color:'#888',fontSize:'11px',margin:'7px 0px'});this.make_timestamp();if(this.with_tags) +KBItemToolbar=function(args,kb){$.extend(this,args);var me=this;this.make=function(){this.wrapper=$a(this.parent,'div','',{});this.line1=$a(this.wrapper,'div','',{color:'#888',fontSize:'11px',margin:'7px 0px'});this.make_timestamp();this.make_answers();if(this.with_tags) this.make_tags();this.setup_del();} this.make_timestamp=function(){this.line1.innerHTML=repl('By %(name)s | %(when)s',{name:wn.utils.full_name(this.det.first_name,this.det.last_name),when:wn.datetime.comment_when(this.det.modified)});if(has_common(user_roles,['Administrator','System Manager'])){this.line1.innerHTML+=' | delete';}} +this.make_answers=function(){if(this.doctype=='Question') +this.line1.innerHTML+=' | '+this.det.answers+' answers'} this.make_tags=function(){this.line1.innerHTML+=' | ' this.tags_area=$a(this.line1,'span','kb-tags') this.tags=new TagList(this.tags_area,this.det._user_tags&&(this.det._user_tags.split(',')),this.doctype,this.det.name,0,kb.set_tag_filter)} From e6ecb0600159c2c1204aa167f1d52f6767d0a99c Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Tue, 7 Aug 2012 12:48:41 +0530 Subject: [PATCH 16/23] added markdown reference page --- .../page/markdown_reference/__init__.py | 0 .../markdown_reference/markdown_reference.css | 0 .../markdown_reference.html | 150 ++++++++++++++++++ .../markdown_reference/markdown_reference.js | 1 + .../markdown_reference/markdown_reference.py | 1 + .../markdown_reference/markdown_reference.txt | 28 ++++ 6 files changed, 180 insertions(+) create mode 100644 erpnext/utilities/page/markdown_reference/__init__.py create mode 100644 erpnext/utilities/page/markdown_reference/markdown_reference.css create mode 100644 erpnext/utilities/page/markdown_reference/markdown_reference.html create mode 100644 erpnext/utilities/page/markdown_reference/markdown_reference.js create mode 100644 erpnext/utilities/page/markdown_reference/markdown_reference.py create mode 100644 erpnext/utilities/page/markdown_reference/markdown_reference.txt diff --git a/erpnext/utilities/page/markdown_reference/__init__.py b/erpnext/utilities/page/markdown_reference/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/erpnext/utilities/page/markdown_reference/markdown_reference.css b/erpnext/utilities/page/markdown_reference/markdown_reference.css new file mode 100644 index 0000000000..e69de29bb2 diff --git a/erpnext/utilities/page/markdown_reference/markdown_reference.html b/erpnext/utilities/page/markdown_reference/markdown_reference.html new file mode 100644 index 0000000000..5af414f275 --- /dev/null +++ b/erpnext/utilities/page/markdown_reference/markdown_reference.html @@ -0,0 +1,150 @@ +
+
+
+ Markdown Reference + × +
+
+
+
+

Phrase Emphasis

+
*italic*   **bold**
+_italic_   __bold__
+
+ +

Links

+ +

Inline:

+ +
An [example](http://url.com/ "Title")
+
+ +

Reference-style labels (titles are optional):

+ +
An [example][id]. Then, anywhere
+else in the doc, define the link:
+
+   [id]: http://example.com/  "Title"
+
+ +

Images

+ +

Inline (titles are optional):

+ +
![alt text](/path/img.jpg "Title")
+
+ +

Reference-style:

+ +
![alt text][id]
+
+    [id]: /url/to/img.jpg "Title"
+
+ +

Headers

+ +

Setext-style:

+ +
Header 1
+========
+
+Header 2
+--------
+
+
+ +

atx-style (closing #'s are optional):

+ +
# Header 1 #
+
+
+
+ +

Lists

+ +

Ordered, without paragraphs:

+ +
1.  Foo
+2.  Bar
+
+ +

Unordered, with paragraphs:

+ +
*   A list item.
+
+    With multiple paragraphs.
+
+*   Bar
+
+ +

You can nest them:

+ +
*   Abacus
+    * ass
+*   Bastard
+    1.  bitch
+    2.  bupkis
+        * BELITTLER
+    3. burper
+*   Cunning
+
+ +

Blockquotes

+ +
> Email-style angle brackets
+
+> are used for blockquotes.
+
+> > And, they can be nested.
+
+> >
+> * You can quote a list.
+> * Etc.
+
+ +

Code Spans

+ +
`<code>` spans are delimited
+by backticks.
+
+You can include literal backticks
+like `` `this` ``.
+
+ +

Preformatted Code Blocks

+ +

Indent every line of a code block by at least 4 spaces or 1 tab, and use a colon at the end of the preceding paragraph.

+ +
This is a normal paragraph:
+
+    This is a preformatted
+    code block.
+
+Preceded by a space, the colon
+disappears. :
+
+    This is a preformatted
+    code block.
+
+ +

Horizontal Rules

+ +

Three or more dashes or asterisks:

+ +
---
+
+* * *
+
+- - - -
+
+ +

Manual Line Breaks

+ +

End a line with two or more spaces:

+ +
Roses are red,
+Violets are blue.
+
+
+
+
\ No newline at end of file diff --git a/erpnext/utilities/page/markdown_reference/markdown_reference.js b/erpnext/utilities/page/markdown_reference/markdown_reference.js new file mode 100644 index 0000000000..8e8fbac2c9 --- /dev/null +++ b/erpnext/utilities/page/markdown_reference/markdown_reference.js @@ -0,0 +1 @@ +wn.pages['markdown-reference'].onload = function(wrapper) { } \ No newline at end of file diff --git a/erpnext/utilities/page/markdown_reference/markdown_reference.py b/erpnext/utilities/page/markdown_reference/markdown_reference.py new file mode 100644 index 0000000000..f807eb0a4d --- /dev/null +++ b/erpnext/utilities/page/markdown_reference/markdown_reference.py @@ -0,0 +1 @@ +import webnotes \ No newline at end of file diff --git a/erpnext/utilities/page/markdown_reference/markdown_reference.txt b/erpnext/utilities/page/markdown_reference/markdown_reference.txt new file mode 100644 index 0000000000..304f2e3de9 --- /dev/null +++ b/erpnext/utilities/page/markdown_reference/markdown_reference.txt @@ -0,0 +1,28 @@ +# Page, markdown-reference +[ + + # These values are common in all dictionaries + { + 'creation': '2012-08-07 12:35:30', + 'docstatus': 0, + 'modified': '2012-08-07 12:35:30', + 'modified_by': u'Administrator', + 'owner': u'Administrator' + }, + + # These values are common for all Page + { + 'doctype': 'Page', + 'module': u'Utilities', + 'name': '__common__', + 'page_name': u'Markdown Reference', + 'standard': u'Yes', + 'title': u'Markdown Reference' + }, + + # Page, markdown-reference + { + 'doctype': 'Page', + 'name': u'markdown-reference' + } +] \ No newline at end of file From 6252c13ec850b564f9fcec3060b9fa88b440b263 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Tue, 7 Aug 2012 12:53:49 +0530 Subject: [PATCH 17/23] added code style and mardown in todo --- erpnext/utilities/page/kb_common/kb_common.js | 2 +- erpnext/utilities/page/questions/questions.py | 2 +- erpnext/utilities/page/todo/todo.js | 6 ++++-- erpnext/utilities/page/todo/todo.py | 1 + public/css/all-app.css | 20 ++++++++++++++++++- public/css/all-web.css | 20 ++++++++++++++++++- public/js/all-app.js | 2 +- public/js/kb_common.js | 3 +-- 8 files changed, 47 insertions(+), 9 deletions(-) diff --git a/erpnext/utilities/page/kb_common/kb_common.js b/erpnext/utilities/page/kb_common/kb_common.js index a135612d7e..9d6b7e8e0b 100644 --- a/erpnext/utilities/page/kb_common/kb_common.js +++ b/erpnext/utilities/page/kb_common/kb_common.js @@ -93,7 +93,7 @@ EditableText = function(args) {
\ [edit]\ \ - \ \ Cancel\ diff --git a/erpnext/utilities/page/questions/questions.py b/erpnext/utilities/page/questions/questions.py index bd9efc7385..7420d5f8c9 100644 --- a/erpnext/utilities/page/questions/questions.py +++ b/erpnext/utilities/page/questions/questions.py @@ -49,7 +49,7 @@ def add_question(arg): from webnotes.model.doc import Document d = Document('Question') - d.question = args['question'].title() + d.question = args['question'] d.points = 1 d.save(1) diff --git a/erpnext/utilities/page/todo/todo.js b/erpnext/utilities/page/todo/todo.js index 786e757e29..1ab8982778 100644 --- a/erpnext/utilities/page/todo/todo.js +++ b/erpnext/utilities/page/todo/todo.js @@ -89,7 +89,7 @@ erpnext.todo.ToDoItem = Class.extend({ } if(!todo.description) todo.description = ''; - todo.desc = todo.description.replace(/\n/g, "
"); + todo.desc = wn.markdown(todo.description); $(parent_list).append(repl('\
\ @@ -145,7 +145,9 @@ erpnext.todo.make_dialog = function(det) { title: 'To Do', fields: [ {fieldtype:'Date', fieldname:'date', label:'Event Date', reqd:1}, - {fieldtype:'Text', fieldname:'description', label:'Description', reqd:1}, + {fieldtype:'Text', fieldname:'description', label:'Description', + reqd:1, description:'Use markdown to \ + format content'}, {fieldtype:'Check', fieldname:'checked', label:'Completed'}, {fieldtype:'Select', fieldname:'priority', label:'Priority', reqd:1, 'options':['Medium','High','Low'].join('\n')}, {fieldtype:'Button', fieldname:'save', label:'Save'} diff --git a/erpnext/utilities/page/todo/todo.py b/erpnext/utilities/page/todo/todo.py index 1b54478eca..05c695d248 100644 --- a/erpnext/utilities/page/todo/todo.py +++ b/erpnext/utilities/page/todo/todo.py @@ -28,6 +28,7 @@ def get(arg=None): @webnotes.whitelist() def edit(arg=None): + import markdown2 args = webnotes.form_dict d = Document('ToDo', args.get('name') or None) diff --git a/public/css/all-app.css b/public/css/all-app.css index ecdbe652f9..f120a8bd73 100644 --- a/public/css/all-app.css +++ b/public/css/all-app.css @@ -1969,7 +1969,25 @@ span, div, td, input, textarea, button, select { } -pre { margin: 0px; padding: 0px; } +pre { + background-color: #F5F5F5; + border: 1px solid rgba(0, 0, 0, 0.15); + border-radius: 4px 4px 4px 4px; + display: block; + font-size: 12.025px; + line-height: 18px; + margin: 0 0 15px; + padding: 8.5px; + white-space: pre-wrap; + word-wrap: break-word; +} + +code, pre { + border-radius: 3px 3px 3px 3px; + color: #333333; + font-family: Menlo,Monaco,Consolas,"Courier New",monospace; + font-size: 12px; +} button { margin: 2px; margin-left: 0px; } diff --git a/public/css/all-web.css b/public/css/all-web.css index 332471b01b..b27a7dac47 100644 --- a/public/css/all-web.css +++ b/public/css/all-web.css @@ -1830,7 +1830,25 @@ span, div, td, input, textarea, button, select { } -pre { margin: 0px; padding: 0px; } +pre { + background-color: #F5F5F5; + border: 1px solid rgba(0, 0, 0, 0.15); + border-radius: 4px 4px 4px 4px; + display: block; + font-size: 12.025px; + line-height: 18px; + margin: 0 0 15px; + padding: 8.5px; + white-space: pre-wrap; + word-wrap: break-word; +} + +code, pre { + border-radius: 3px 3px 3px 3px; + color: #333333; + font-family: Menlo,Monaco,Consolas,"Courier New",monospace; + font-size: 12px; +} button { margin: 2px; margin-left: 0px; } diff --git a/public/js/all-app.js b/public/js/all-app.js index 6d6c820aa4..0620d3b0d6 100644 --- a/public/js/all-app.js +++ b/public/js/all-app.js @@ -1895,7 +1895,7 @@ if(cur_frm.editable&&cur_frm.doc.docstatus>0){if(this.df.allow_on_submit&&cur_fr if(this.df['default'].toLowerCase()=='no add rows'){this.grid.can_add_rows=false;}} if(st=='Write'){this.grid.show();}else if(st=='Read'){this.grid.show();}else{this.grid.hide();} this.grid.refresh();} -_f.TableField.prototype.set=function(v){};_f.TableField.prototype.set_input=function(v){};_f.CodeField=function(){};_f.CodeField.prototype=new Field();_f.CodeField.prototype.make_input=function(){var me=this;this.label_span.innerHTML=this.df.label;if(this.df.fieldtype=='Text Editor'){this.input=$a(this.input_area,'text_area','',{fontSize:'12px'});this.myid=wn.dom.set_unique_id(this.input);$(me.input).tinymce({script_url:'js/lib/tiny_mce_33/tiny_mce.js',theme:"advanced",plugins:"style,inlinepopups,table",extended_valid_elements:"div[id|dir|class|align|style]",width:'100%',height:'360px',theme_advanced_buttons1:"bold,italic,underline,strikethrough,hr,|,justifyleft,justifycenter,justifyright,|,formatselect,fontselect,fontsizeselect",theme_advanced_buttons2:"bullist,numlist,|,outdent,indent,|,undo,redo,|,link,unlink,code,|,forecolor,backcolor,|,tablecontrols",theme_advanced_buttons3:"",theme_advanced_toolbar_location:"top",theme_advanced_toolbar_align:"left",content_css:"js/lib/tiny_mce_33/custom_content.css",oninit:function(){me.init_editor();}});this.input.set_input=function(v){if(me.editor){me.editor.setContent(v);}else{$(me.input).val(v);}} +_f.TableField.prototype.set=function(v){};_f.TableField.prototype.set_input=function(v){};_f.CodeField=function(){};_f.CodeField.prototype=new Field();_f.CodeField.prototype.make_input=function(){var me=this;this.label_span.innerHTML=this.df.label;if(this.df.fieldtype=='Text Editor'){this.input=$a(this.input_area,'text_area','',{fontSize:'12px'});this.myid=wn.dom.set_unique_id(this.input);$(me.input).tinymce({script_url:'js/lib/tiny_mce_33/tiny_mce.js',theme:"advanced",plugins:"style,inlinepopups,table",extended_valid_elements:"div[id|dir|class|align|style]",width:'100%',height:'360px',theme_advanced_buttons1:"bold,italic,underline,strikethrough,hr,|,justifyleft,justifycenter,justifyright,|,formatselect,fontselect,fontsizeselect",theme_advanced_buttons2:"bullist,numlist,|,outdent,indent,|,undo,redo,|,link,unlink,code,|,forecolor,backcolor,|,tablecontrols",theme_advanced_buttons3:"",theme_advanced_toolbar_location:"top",theme_advanced_toolbar_align:"left",content_css:"js/lib/tiny_mce_33/custom_content.css?q=1",oninit:function(){me.init_editor();}});this.input.set_input=function(v){if(me.editor){me.editor.setContent(v);}else{$(me.input).val(v);}} this.input.onchange=function(){me.set(me.editor.getContent());me.run_trigger();} this.get_value=function(){return me.editor.getContent();}}else{wn.require('js/lib/ace/ace.js');$(this.input_area).css('border','1px solid #aaa');this.pre=$a(this.input_area,'pre','',{position:'relative',height:'400px',width:'100%'});this.input={};this.myid=wn.dom.set_unique_id(this.pre);this.editor=ace.edit(this.myid);if(me.df.options=='Markdown'||me.df.options=='HTML'){wn.require('js/lib/ace/mode-html.js');var HTMLMode=require("ace/mode/html").Mode;me.editor.getSession().setMode(new HTMLMode());} else if(me.df.options=='Javascript'){wn.require('js/lib/ace/mode-javascript.js');var JavascriptMode=require("ace/mode/javascript").Mode;me.editor.getSession().setMode(new JavascriptMode());} diff --git a/public/js/kb_common.js b/public/js/kb_common.js index d478cac368..bbd57f10e6 100644 --- a/public/js/kb_common.js +++ b/public/js/kb_common.js @@ -6,8 +6,7 @@ KBItemToolbar=function(args,kb){$.extend(this,args);var me=this;this.make=functi this.make_tags();this.setup_del();} this.make_timestamp=function(){this.line1.innerHTML=repl('By %(name)s | %(when)s',{name:wn.utils.full_name(this.det.first_name,this.det.last_name),when:wn.datetime.comment_when(this.det.modified)});if(has_common(user_roles,['Administrator','System Manager'])){this.line1.innerHTML+=' | delete';}} -this.make_answers=function(){if(this.doctype=='Question') -this.line1.innerHTML+=' | '+this.det.answers+' answers'} +this.make_answers=function(){if(this.doctype=='Question'){if(this.det.answers==0){this.line1.innerHTML+=' | no answers';}else if(this.det.answers==1){this.line1.innerHTML+=' | 1 answer';}else{this.line1.innerHTML+=' | '+this.det.answers+' answers';}}} this.make_tags=function(){this.line1.innerHTML+=' | ' this.tags_area=$a(this.line1,'span','kb-tags') this.tags=new TagList(this.tags_area,this.det._user_tags&&(this.det._user_tags.split(',')),this.doctype,this.det.name,0,kb.set_tag_filter)} From e30d5f833e87e8f115636cf40cd8d94824695910 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Tue, 7 Aug 2012 15:05:42 +0530 Subject: [PATCH 18/23] New Report: Supplier Quotations --- .../Supplier Quotations.txt | 26 +++++++++++++++++++ erpnext/patches/august_2012/__init__.py | 0 .../august_2012/report_supplier_quotations.py | 3 +++ erpnext/patches/patch_list.py | 4 +++ 4 files changed, 33 insertions(+) create mode 100644 erpnext/buying/Report/Supplier Quotations/Supplier Quotations.txt create mode 100644 erpnext/patches/august_2012/__init__.py create mode 100644 erpnext/patches/august_2012/report_supplier_quotations.py diff --git a/erpnext/buying/Report/Supplier Quotations/Supplier Quotations.txt b/erpnext/buying/Report/Supplier Quotations/Supplier Quotations.txt new file mode 100644 index 0000000000..860a432810 --- /dev/null +++ b/erpnext/buying/Report/Supplier Quotations/Supplier Quotations.txt @@ -0,0 +1,26 @@ +# Report, Supplier Quotations +[ + + # These values are common in all dictionaries + { + 'creation': '2012-08-07 14:52:42', + 'docstatus': 0, + 'modified': '2012-08-07 14:57:57', + 'modified_by': u'Administrator', + 'owner': u'Administrator' + }, + + # These values are common for all Report + { + 'doctype': 'Report', + 'json': u'{"filters":[["Supplier Quotation","supplier","like","%%"],["Supplier Quotation Item","item_code","like","%%"]],"columns":[["name","Supplier Quotation"],["supplier","Supplier Quotation"],["item_code","Supplier Quotation Item"],["description","Supplier Quotation Item"],["qty","Supplier Quotation Item"],["currency","Supplier Quotation"],["import_rate","Supplier Quotation Item"],["import_amount","Supplier Quotation Item"]],"sort_by":"modified","sort_order":"desc","sort_by_next":"name","sort_order_next":"desc"}', + 'name': '__common__', + 'ref_doctype': u'Supplier Quotation' + }, + + # Report, Supplier Quotations + { + 'doctype': 'Report', + 'name': u'Supplier Quotations' + } +] \ No newline at end of file diff --git a/erpnext/patches/august_2012/__init__.py b/erpnext/patches/august_2012/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/erpnext/patches/august_2012/report_supplier_quotations.py b/erpnext/patches/august_2012/report_supplier_quotations.py new file mode 100644 index 0000000000..bb0347910b --- /dev/null +++ b/erpnext/patches/august_2012/report_supplier_quotations.py @@ -0,0 +1,3 @@ +def execute(): + from webnotes.modules import reload_doc + reload_doc("buying", "Report", "Supplier Quotations") \ No newline at end of file diff --git a/erpnext/patches/patch_list.py b/erpnext/patches/patch_list.py index f512bfc0e3..83da5c3fa3 100644 --- a/erpnext/patches/patch_list.py +++ b/erpnext/patches/patch_list.py @@ -517,4 +517,8 @@ patch_list = [ 'patch_module': 'patches.july_2012', 'patch_file': 'supplier_quotation', }, + { + 'patch_module': 'patches.august_2012', + 'patch_file': 'report_supplier_quotations', + }, ] \ No newline at end of file From e81c07ff4d403074448402af3ce58aa4a194a26c Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Tue, 7 Aug 2012 15:08:52 +0530 Subject: [PATCH 19/23] appended unicode literals import after merge --- erpnext/patches/august_2012/__init__.py | 1 + erpnext/patches/august_2012/report_supplier_quotations.py | 1 + erpnext/utilities/page/markdown_reference/__init__.py | 1 + erpnext/utilities/page/markdown_reference/markdown_reference.py | 1 + 4 files changed, 4 insertions(+) diff --git a/erpnext/patches/august_2012/__init__.py b/erpnext/patches/august_2012/__init__.py index e69de29bb2..baffc48825 100644 --- a/erpnext/patches/august_2012/__init__.py +++ b/erpnext/patches/august_2012/__init__.py @@ -0,0 +1 @@ +from __future__ import unicode_literals diff --git a/erpnext/patches/august_2012/report_supplier_quotations.py b/erpnext/patches/august_2012/report_supplier_quotations.py index bb0347910b..d2cd3cde76 100644 --- a/erpnext/patches/august_2012/report_supplier_quotations.py +++ b/erpnext/patches/august_2012/report_supplier_quotations.py @@ -1,3 +1,4 @@ +from __future__ import unicode_literals def execute(): from webnotes.modules import reload_doc reload_doc("buying", "Report", "Supplier Quotations") \ No newline at end of file diff --git a/erpnext/utilities/page/markdown_reference/__init__.py b/erpnext/utilities/page/markdown_reference/__init__.py index e69de29bb2..baffc48825 100644 --- a/erpnext/utilities/page/markdown_reference/__init__.py +++ b/erpnext/utilities/page/markdown_reference/__init__.py @@ -0,0 +1 @@ +from __future__ import unicode_literals diff --git a/erpnext/utilities/page/markdown_reference/markdown_reference.py b/erpnext/utilities/page/markdown_reference/markdown_reference.py index f807eb0a4d..fbba0997d8 100644 --- a/erpnext/utilities/page/markdown_reference/markdown_reference.py +++ b/erpnext/utilities/page/markdown_reference/markdown_reference.py @@ -1 +1,2 @@ +from __future__ import unicode_literals import webnotes \ No newline at end of file From 883285f5036d5812f7808a97bcd2cdeab456cb49 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Tue, 7 Aug 2012 15:13:48 +0530 Subject: [PATCH 20/23] fix in supplier quotations patch --- erpnext/patches/august_2012/report_supplier_quotations.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/patches/august_2012/report_supplier_quotations.py b/erpnext/patches/august_2012/report_supplier_quotations.py index bb0347910b..c0e6b3cf54 100644 --- a/erpnext/patches/august_2012/report_supplier_quotations.py +++ b/erpnext/patches/august_2012/report_supplier_quotations.py @@ -1,3 +1,3 @@ def execute(): from webnotes.modules import reload_doc - reload_doc("buying", "Report", "Supplier Quotations") \ No newline at end of file + reload_doc("Buying", "Report", "Supplier Quotations") \ No newline at end of file From 26dc1b776a1f46347f597f54d73b1d97f6915080 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Tue, 7 Aug 2012 15:17:53 +0530 Subject: [PATCH 21/23] fix in report: supplier quotations after merge with unicode --- .../supplier_quotations.txt} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename erpnext/buying/Report/{Supplier Quotations/Supplier Quotations.txt => supplier_quotations/supplier_quotations.txt} (100%) diff --git a/erpnext/buying/Report/Supplier Quotations/Supplier Quotations.txt b/erpnext/buying/Report/supplier_quotations/supplier_quotations.txt similarity index 100% rename from erpnext/buying/Report/Supplier Quotations/Supplier Quotations.txt rename to erpnext/buying/Report/supplier_quotations/supplier_quotations.txt From ebcb3c02d0aa5cbfc722d6eacee47a290b5ba610 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Tue, 7 Aug 2012 15:24:46 +0530 Subject: [PATCH 22/23] fixes in supplier quotations report patch --- erpnext/patches/august_2012/report_supplier_quotations.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/patches/august_2012/report_supplier_quotations.py b/erpnext/patches/august_2012/report_supplier_quotations.py index bcbd176608..8eaf707c4c 100644 --- a/erpnext/patches/august_2012/report_supplier_quotations.py +++ b/erpnext/patches/august_2012/report_supplier_quotations.py @@ -1,4 +1,4 @@ from __future__ import unicode_literals def execute(): from webnotes.modules import reload_doc - reload_doc("Buying", "Report", "Supplier Quotations") + reload_doc("buying", "report", "supplier_quotations") From 7b64b96676b489105e3fb20952d91bf77415c18a Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Tue, 7 Aug 2012 15:30:40 +0530 Subject: [PATCH 23/23] renamed report folder --- .../supplier_quotations/supplier_quotations.txt | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename erpnext/buying/{Report => report}/supplier_quotations/supplier_quotations.txt (100%) diff --git a/erpnext/buying/Report/supplier_quotations/supplier_quotations.txt b/erpnext/buying/report/supplier_quotations/supplier_quotations.txt similarity index 100% rename from erpnext/buying/Report/supplier_quotations/supplier_quotations.txt rename to erpnext/buying/report/supplier_quotations/supplier_quotations.txt