From 5d4a9f8554ef5a5648b2fa09cdab1e5c8bb1f4b4 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Mon, 6 Aug 2012 14:20:15 +0530 Subject: [PATCH 01/11] date format bug fixed --- public/js/all-app.js | 6 +++--- public/js/all-web.js | 2 +- public/js/fields.js | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/public/js/all-app.js b/public/js/all-app.js index df69de633f..3c50ed2ebd 100644 --- a/public/js/all-app.js +++ b/public/js/all-app.js @@ -478,7 +478,7 @@ if(d.search('-')!=-1){var t=d.split('-');return new Date(t[0],t[1]-1,t[2],tm[0], new_dt=new Date(dt.getFullYear(),dt.getMonth()+months,dt.getDate()) if(new_dt.getDate()!=dt.getDate()){return dateutil.month_end(new Date(dt.getFullYear(),dt.getMonth()+months,1))} return dateutil.obj_to_str(new_dt);},month_start:function(){var d=new Date();return d.getFullYear()+'-'+int_to_str(d.getMonth()+1,2)+'-01';},month_end:function(d){if(!d)var d=new Date();var m=d.getMonth()+1;var y=d.getFullYear();last_date=month_last[m];if(m==2&&(y%4)==0&&((y%100)!=0||(y%400)==0)) -last_date=29;return y+'-'+int_to_str(m,2)+'-'+last_date;},get_user_fmt:function(){var t=wn.control_panel.date_format;if(!t)t='dd-mm-yyyy';return t;},str_to_user:function(val,no_time_str){var user_fmt=dateutil.get_user_fmt();var time_str='';if(val==null||val=='')return null;if(val.search(':')!=-1){var tmp=val.split(' ');if(tmp[1]) +last_date=29;return y+'-'+int_to_str(m,2)+'-'+last_date;},get_user_fmt:function(){var t=sys_defaults.date_format;if(!t)t='dd-mm-yyyy';return t;},str_to_user:function(val,no_time_str){var user_fmt=dateutil.get_user_fmt();var time_str='';if(val==null||val=='')return null;if(val.search(':')!=-1){var tmp=val.split(' ');if(tmp[1]) time_str=' '+tmp[1];var d=tmp[0];}else{var d=val;} if(no_time_str)time_str='';d=d.split('-');if(d.length==3){if(user_fmt=='dd-mm-yyyy') val=d[2]+'-'+d[1]+'-'+d[0]+time_str;else if(user_fmt=='dd/mm/yyyy') @@ -719,7 +719,7 @@ ReadOnlyField.prototype=new Field();function HTMLField(){} HTMLField.prototype=new Field();HTMLField.prototype.with_label=0;HTMLField.prototype.set_disp=function(val){this.disp_area.innerHTML=val;} HTMLField.prototype.set_input=function(val){if(val)this.set_disp(val);} HTMLField.prototype.onrefresh=function(){this.set_disp(this.df.options?this.df.options:'');} -var datepicker_active=0;function DateField(){}DateField.prototype=new Field();DateField.prototype.make_input=function(){var me=this;this.user_fmt=wn.control_panel.date_format;if(!this.user_fmt)this.user_fmt='dd-mm-yy';this.input=$a(this.input_area,'input');$(this.input).datepicker({dateFormat:me.user_fmt.replace('yyyy','yy'),altFormat:'yy-mm-dd',changeYear:true,beforeShow:function(input,inst){datepicker_active=1},onClose:function(dateText,inst){datepicker_active=0;if(_f.cur_grid_cell) +var datepicker_active=0;function DateField(){}DateField.prototype=new Field();DateField.prototype.make_input=function(){var me=this;this.user_fmt=sys_defaults.date_format;if(!this.user_fmt)this.user_fmt='dd-mm-yy';this.input=$a(this.input_area,'input');$(this.input).datepicker({dateFormat:me.user_fmt.replace('yyyy','yy'),altFormat:'yy-mm-dd',changeYear:true,beforeShow:function(input,inst){datepicker_active=1},onClose:function(dateText,inst){datepicker_active=0;if(_f.cur_grid_cell) _f.cur_grid_cell.grid.cell_deselect();}});var me=this;me.input.onchange=function(){if(this.value==null)this.value='';if(!this.not_in_form) me.set(dateutil.user_to_str(me.input.value));me.run_trigger();} me.input.set_input=function(val){if(val==null)val='';else val=dateutil.str_to_user(val);me.input.value=val;} @@ -1546,7 +1546,7 @@ ReadOnlyField.prototype=new Field();function HTMLField(){} HTMLField.prototype=new Field();HTMLField.prototype.with_label=0;HTMLField.prototype.set_disp=function(val){this.disp_area.innerHTML=val;} HTMLField.prototype.set_input=function(val){if(val)this.set_disp(val);} HTMLField.prototype.onrefresh=function(){this.set_disp(this.df.options?this.df.options:'');} -var datepicker_active=0;function DateField(){}DateField.prototype=new Field();DateField.prototype.make_input=function(){var me=this;this.user_fmt=wn.control_panel.date_format;if(!this.user_fmt)this.user_fmt='dd-mm-yy';this.input=$a(this.input_area,'input');$(this.input).datepicker({dateFormat:me.user_fmt.replace('yyyy','yy'),altFormat:'yy-mm-dd',changeYear:true,beforeShow:function(input,inst){datepicker_active=1},onClose:function(dateText,inst){datepicker_active=0;if(_f.cur_grid_cell) +var datepicker_active=0;function DateField(){}DateField.prototype=new Field();DateField.prototype.make_input=function(){var me=this;this.user_fmt=sys_defaults.date_format;if(!this.user_fmt)this.user_fmt='dd-mm-yy';this.input=$a(this.input_area,'input');$(this.input).datepicker({dateFormat:me.user_fmt.replace('yyyy','yy'),altFormat:'yy-mm-dd',changeYear:true,beforeShow:function(input,inst){datepicker_active=1},onClose:function(dateText,inst){datepicker_active=0;if(_f.cur_grid_cell) _f.cur_grid_cell.grid.cell_deselect();}});var me=this;me.input.onchange=function(){if(this.value==null)this.value='';if(!this.not_in_form) me.set(dateutil.user_to_str(me.input.value));me.run_trigger();} me.input.set_input=function(val){if(val==null)val='';else val=dateutil.str_to_user(val);me.input.value=val;} diff --git a/public/js/all-web.js b/public/js/all-web.js index 5a4a4a19c3..c52a51ad3f 100644 --- a/public/js/all-web.js +++ b/public/js/all-web.js @@ -365,7 +365,7 @@ if(d.search('-')!=-1){var t=d.split('-');return new Date(t[0],t[1]-1,t[2],tm[0], new_dt=new Date(dt.getFullYear(),dt.getMonth()+months,dt.getDate()) if(new_dt.getDate()!=dt.getDate()){return dateutil.month_end(new Date(dt.getFullYear(),dt.getMonth()+months,1))} return dateutil.obj_to_str(new_dt);},month_start:function(){var d=new Date();return d.getFullYear()+'-'+int_to_str(d.getMonth()+1,2)+'-01';},month_end:function(d){if(!d)var d=new Date();var m=d.getMonth()+1;var y=d.getFullYear();last_date=month_last[m];if(m==2&&(y%4)==0&&((y%100)!=0||(y%400)==0)) -last_date=29;return y+'-'+int_to_str(m,2)+'-'+last_date;},get_user_fmt:function(){var t=wn.control_panel.date_format;if(!t)t='dd-mm-yyyy';return t;},str_to_user:function(val,no_time_str){var user_fmt=dateutil.get_user_fmt();var time_str='';if(val==null||val=='')return null;if(val.search(':')!=-1){var tmp=val.split(' ');if(tmp[1]) +last_date=29;return y+'-'+int_to_str(m,2)+'-'+last_date;},get_user_fmt:function(){var t=sys_defaults.date_format;if(!t)t='dd-mm-yyyy';return t;},str_to_user:function(val,no_time_str){var user_fmt=dateutil.get_user_fmt();var time_str='';if(val==null||val=='')return null;if(val.search(':')!=-1){var tmp=val.split(' ');if(tmp[1]) time_str=' '+tmp[1];var d=tmp[0];}else{var d=val;} if(no_time_str)time_str='';d=d.split('-');if(d.length==3){if(user_fmt=='dd-mm-yyyy') val=d[2]+'-'+d[1]+'-'+d[0]+time_str;else if(user_fmt=='dd/mm/yyyy') diff --git a/public/js/fields.js b/public/js/fields.js index 32aa00c934..c85c8c297e 100644 --- a/public/js/fields.js +++ b/public/js/fields.js @@ -83,7 +83,7 @@ ReadOnlyField.prototype=new Field();function HTMLField(){} HTMLField.prototype=new Field();HTMLField.prototype.with_label=0;HTMLField.prototype.set_disp=function(val){this.disp_area.innerHTML=val;} HTMLField.prototype.set_input=function(val){if(val)this.set_disp(val);} HTMLField.prototype.onrefresh=function(){this.set_disp(this.df.options?this.df.options:'');} -var datepicker_active=0;function DateField(){}DateField.prototype=new Field();DateField.prototype.make_input=function(){var me=this;this.user_fmt=wn.control_panel.date_format;if(!this.user_fmt)this.user_fmt='dd-mm-yy';this.input=$a(this.input_area,'input');$(this.input).datepicker({dateFormat:me.user_fmt.replace('yyyy','yy'),altFormat:'yy-mm-dd',changeYear:true,beforeShow:function(input,inst){datepicker_active=1},onClose:function(dateText,inst){datepicker_active=0;if(_f.cur_grid_cell) +var datepicker_active=0;function DateField(){}DateField.prototype=new Field();DateField.prototype.make_input=function(){var me=this;this.user_fmt=sys_defaults.date_format;if(!this.user_fmt)this.user_fmt='dd-mm-yy';this.input=$a(this.input_area,'input');$(this.input).datepicker({dateFormat:me.user_fmt.replace('yyyy','yy'),altFormat:'yy-mm-dd',changeYear:true,beforeShow:function(input,inst){datepicker_active=1},onClose:function(dateText,inst){datepicker_active=0;if(_f.cur_grid_cell) _f.cur_grid_cell.grid.cell_deselect();}});var me=this;me.input.onchange=function(){if(this.value==null)this.value='';if(!this.not_in_form) me.set(dateutil.user_to_str(me.input.value));me.run_trigger();} me.input.set_input=function(val){if(val==null)val='';else val=dateutil.str_to_user(val);me.input.value=val;} From ed8049ec19a5276c9077a1ca2070b27b050a1e27 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Mon, 6 Aug 2012 14:31:45 +0530 Subject: [PATCH 02/11] 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/11] 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/11] 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/11] 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/11] 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/11] 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/11] 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/11] 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/11] 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/11] 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',