From f4b552ea5d1cb4b70f76f70fac7aedf43c658024 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Tue, 19 Jun 2012 13:17:56 +0530 Subject: [PATCH 01/13] fixed: link field validate data on defocus, if autosuggest or search not used --- public/js/all-app.js | 18 ++++++++++-------- public/js/fields.js | 9 +++++---- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/public/js/all-app.js b/public/js/all-app.js index 0ee5f2bfe5..095d8c3a00 100644 --- a/public/js/all-app.js +++ b/public/js/all-app.js @@ -734,19 +734,20 @@ return v;};function LinkField(){}LinkField.prototype=new Field();LinkField.proto $(me.btn2).css('display','inline-block');else $dh(me.btn2);}} me.txt.field_object=this;me.input.set_input=function(val){if(val==undefined)val='';me.txt.value=val;} me.get_value=function(){return me.txt.value;} -$(me.txt).autocomplete({source:function(request,response){wn.call({method:'webnotes.widgets.search.search_link',args:{'txt':request.term,'dt':me.df.options,'query':me.get_custom_query()},callback:function(r){response(r.results);},});},select:function(event,ui){me.set_input_value(ui.item.value);}}).data('autocomplete')._renderItem=function(ul,item){return $('
  • ').data('item.autocomplete',item).append(repl('%(label)s
    %(info)s
    ',item)).appendTo(ul);};$(this.txt).change(function(){if(!$(this).val()){if(selector&&selector.display) -return;me.set_input_value('');}})} +$(me.txt).autocomplete({source:function(request,response){wn.call({method:'webnotes.widgets.search.search_link',args:{'txt':request.term,'dt':me.df.options,'query':me.get_custom_query()},callback:function(r){response(r.results);},});},select:function(event,ui){me.set_input_value(ui.item.value);}}).data('autocomplete')._renderItem=function(ul,item){return $('
  • ').data('item.autocomplete',item).append(repl('%(label)s
    %(info)s
    ',item)).appendTo(ul);};$(this.txt).change(function(){var val=$(this).val();me.set_input_value_executed=false;if(!val){if(selector&&selector.display) +return;me.set_input_value('');}else{setTimeout(function(){if(!me.set_input_value_executed){me.set_input_value(val);}},100);}})} LinkField.prototype.get_custom_query=function(){this.set_get_query();if(this.get_query){if(cur_frm) var doc=locals[cur_frm.doctype][cur_frm.docname];return this.get_query(doc,this.doctype,this.docname);}} LinkField.prototype.setup_buttons=function(){var me=this;me.btn.onclick=function(){selector.set(me,me.df.options,me.df.label);selector.show(me.txt);} if(me.btn1)me.btn1.onclick=function(){if(me.txt.value&&me.df.options){loaddoc(me.df.options,me.txt.value);}} me.can_create=0;if((!me.not_in_form)&&in_list(profile.can_create,me.df.options)){me.can_create=1;me.btn2.onclick=function(){var on_save_callback=function(new_rec){if(new_rec){var d=_f.calling_doc_stack.pop();locals[d[0]][d[1]][me.df.fieldname]=new_rec;me.refresh();if(me.grid)me.grid.refresh();me.run_trigger();}} _f.calling_doc_stack.push([me.doctype,me.docname]);new_doc(me.df.options,me.on_new,1,on_save_callback,me.doctype,me.docname,me.frm.not_in_container);}}else{$dh(me.btn2);$y($td(me.tab,0,2),{width:'0px'});}} -LinkField.prototype.set_input_value=function(val){var me=this;var from_selector=false;if(selector&&selector.display)from_selector=true;me.refresh_label_icon();if(me.not_in_form){$(this.txt).val(val);return;} +LinkField.prototype.set_input_value=function(val){var me=this;me.set_input_value_executed=true;var from_selector=false;if(selector&&selector.display)from_selector=true;me.refresh_label_icon();if(me.not_in_form){$(this.txt).val(val);return;} if(cur_frm){if(val==locals[me.doctype][me.docname][me.df.fieldname]){me.run_trigger();return;}} me.set(val);if(_f.cur_grid_cell) _f.cur_grid_cell.grid.cell_deselect();if(locals[me.doctype][me.docname][me.df.fieldname]&&!val){me.run_trigger();return;} -var fetch='';if(cur_frm.fetch_dict[me.df.fieldname]) +me.validate_link(val,from_selector);} +LinkField.prototype.validate_link=function(val,from_selector){var me=this;var fetch='';if(cur_frm.fetch_dict[me.df.fieldname]) fetch=cur_frm.fetch_dict[me.df.fieldname].columns.join(', ');$c('webnotes.widgets.form.utils.validate_link',{'value':val,'options':me.df.options,'fetch':fetch},function(r,rt){if(r.message=='Ok'){if($(me.txt).val()!=val){if((me.grid&&!from_selector)||(!me.grid)){$(me.txt).val(val);}} if(r.fetch_values) me.set_fetch_values(r.fetch_values);me.run_trigger();}else{var astr='';if(in_list(profile.can_create,me.df.options))astr=repl('

    Click here to create a new %(dtl)s',{dt:me.df.options,dtl:get_doctype_label(me.df.options)}) @@ -1557,19 +1558,20 @@ return v;};function LinkField(){}LinkField.prototype=new Field();LinkField.proto $(me.btn2).css('display','inline-block');else $dh(me.btn2);}} me.txt.field_object=this;me.input.set_input=function(val){if(val==undefined)val='';me.txt.value=val;} me.get_value=function(){return me.txt.value;} -$(me.txt).autocomplete({source:function(request,response){wn.call({method:'webnotes.widgets.search.search_link',args:{'txt':request.term,'dt':me.df.options,'query':me.get_custom_query()},callback:function(r){response(r.results);},});},select:function(event,ui){me.set_input_value(ui.item.value);}}).data('autocomplete')._renderItem=function(ul,item){return $('
  • ').data('item.autocomplete',item).append(repl('%(label)s
    %(info)s
    ',item)).appendTo(ul);};$(this.txt).change(function(){if(!$(this).val()){if(selector&&selector.display) -return;me.set_input_value('');}})} +$(me.txt).autocomplete({source:function(request,response){wn.call({method:'webnotes.widgets.search.search_link',args:{'txt':request.term,'dt':me.df.options,'query':me.get_custom_query()},callback:function(r){response(r.results);},});},select:function(event,ui){me.set_input_value(ui.item.value);}}).data('autocomplete')._renderItem=function(ul,item){return $('
  • ').data('item.autocomplete',item).append(repl('%(label)s
    %(info)s
    ',item)).appendTo(ul);};$(this.txt).change(function(){var val=$(this).val();me.set_input_value_executed=false;if(!val){if(selector&&selector.display) +return;me.set_input_value('');}else{setTimeout(function(){if(!me.set_input_value_executed){me.set_input_value(val);}},100);}})} LinkField.prototype.get_custom_query=function(){this.set_get_query();if(this.get_query){if(cur_frm) var doc=locals[cur_frm.doctype][cur_frm.docname];return this.get_query(doc,this.doctype,this.docname);}} LinkField.prototype.setup_buttons=function(){var me=this;me.btn.onclick=function(){selector.set(me,me.df.options,me.df.label);selector.show(me.txt);} if(me.btn1)me.btn1.onclick=function(){if(me.txt.value&&me.df.options){loaddoc(me.df.options,me.txt.value);}} me.can_create=0;if((!me.not_in_form)&&in_list(profile.can_create,me.df.options)){me.can_create=1;me.btn2.onclick=function(){var on_save_callback=function(new_rec){if(new_rec){var d=_f.calling_doc_stack.pop();locals[d[0]][d[1]][me.df.fieldname]=new_rec;me.refresh();if(me.grid)me.grid.refresh();me.run_trigger();}} _f.calling_doc_stack.push([me.doctype,me.docname]);new_doc(me.df.options,me.on_new,1,on_save_callback,me.doctype,me.docname,me.frm.not_in_container);}}else{$dh(me.btn2);$y($td(me.tab,0,2),{width:'0px'});}} -LinkField.prototype.set_input_value=function(val){var me=this;var from_selector=false;if(selector&&selector.display)from_selector=true;me.refresh_label_icon();if(me.not_in_form){$(this.txt).val(val);return;} +LinkField.prototype.set_input_value=function(val){var me=this;me.set_input_value_executed=true;var from_selector=false;if(selector&&selector.display)from_selector=true;me.refresh_label_icon();if(me.not_in_form){$(this.txt).val(val);return;} if(cur_frm){if(val==locals[me.doctype][me.docname][me.df.fieldname]){me.run_trigger();return;}} me.set(val);if(_f.cur_grid_cell) _f.cur_grid_cell.grid.cell_deselect();if(locals[me.doctype][me.docname][me.df.fieldname]&&!val){me.run_trigger();return;} -var fetch='';if(cur_frm.fetch_dict[me.df.fieldname]) +me.validate_link(val,from_selector);} +LinkField.prototype.validate_link=function(val,from_selector){var me=this;var fetch='';if(cur_frm.fetch_dict[me.df.fieldname]) fetch=cur_frm.fetch_dict[me.df.fieldname].columns.join(', ');$c('webnotes.widgets.form.utils.validate_link',{'value':val,'options':me.df.options,'fetch':fetch},function(r,rt){if(r.message=='Ok'){if($(me.txt).val()!=val){if((me.grid&&!from_selector)||(!me.grid)){$(me.txt).val(val);}} if(r.fetch_values) me.set_fetch_values(r.fetch_values);me.run_trigger();}else{var astr='';if(in_list(profile.can_create,me.df.options))astr=repl('

    Click here to create a new %(dtl)s',{dt:me.df.options,dtl:get_doctype_label(me.df.options)}) diff --git a/public/js/fields.js b/public/js/fields.js index dba9e5c249..dbd77c015a 100644 --- a/public/js/fields.js +++ b/public/js/fields.js @@ -98,19 +98,20 @@ return v;};function LinkField(){}LinkField.prototype=new Field();LinkField.proto $(me.btn2).css('display','inline-block');else $dh(me.btn2);}} me.txt.field_object=this;me.input.set_input=function(val){if(val==undefined)val='';me.txt.value=val;} me.get_value=function(){return me.txt.value;} -$(me.txt).autocomplete({source:function(request,response){wn.call({method:'webnotes.widgets.search.search_link',args:{'txt':request.term,'dt':me.df.options,'query':me.get_custom_query()},callback:function(r){response(r.results);},});},select:function(event,ui){me.set_input_value(ui.item.value);}}).data('autocomplete')._renderItem=function(ul,item){return $('
  • ').data('item.autocomplete',item).append(repl('%(label)s
    %(info)s
    ',item)).appendTo(ul);};$(this.txt).change(function(){if(!$(this).val()){if(selector&&selector.display) -return;me.set_input_value('');}})} +$(me.txt).autocomplete({source:function(request,response){wn.call({method:'webnotes.widgets.search.search_link',args:{'txt':request.term,'dt':me.df.options,'query':me.get_custom_query()},callback:function(r){response(r.results);},});},select:function(event,ui){me.set_input_value(ui.item.value);}}).data('autocomplete')._renderItem=function(ul,item){return $('
  • ').data('item.autocomplete',item).append(repl('%(label)s
    %(info)s
    ',item)).appendTo(ul);};$(this.txt).change(function(){var val=$(this).val();me.set_input_value_executed=false;if(!val){if(selector&&selector.display) +return;me.set_input_value('');}else{setTimeout(function(){if(!me.set_input_value_executed){me.set_input_value(val);}},100);}})} LinkField.prototype.get_custom_query=function(){this.set_get_query();if(this.get_query){if(cur_frm) var doc=locals[cur_frm.doctype][cur_frm.docname];return this.get_query(doc,this.doctype,this.docname);}} LinkField.prototype.setup_buttons=function(){var me=this;me.btn.onclick=function(){selector.set(me,me.df.options,me.df.label);selector.show(me.txt);} if(me.btn1)me.btn1.onclick=function(){if(me.txt.value&&me.df.options){loaddoc(me.df.options,me.txt.value);}} me.can_create=0;if((!me.not_in_form)&&in_list(profile.can_create,me.df.options)){me.can_create=1;me.btn2.onclick=function(){var on_save_callback=function(new_rec){if(new_rec){var d=_f.calling_doc_stack.pop();locals[d[0]][d[1]][me.df.fieldname]=new_rec;me.refresh();if(me.grid)me.grid.refresh();me.run_trigger();}} _f.calling_doc_stack.push([me.doctype,me.docname]);new_doc(me.df.options,me.on_new,1,on_save_callback,me.doctype,me.docname,me.frm.not_in_container);}}else{$dh(me.btn2);$y($td(me.tab,0,2),{width:'0px'});}} -LinkField.prototype.set_input_value=function(val){var me=this;var from_selector=false;if(selector&&selector.display)from_selector=true;me.refresh_label_icon();if(me.not_in_form){$(this.txt).val(val);return;} +LinkField.prototype.set_input_value=function(val){var me=this;me.set_input_value_executed=true;var from_selector=false;if(selector&&selector.display)from_selector=true;me.refresh_label_icon();if(me.not_in_form){$(this.txt).val(val);return;} if(cur_frm){if(val==locals[me.doctype][me.docname][me.df.fieldname]){me.run_trigger();return;}} me.set(val);if(_f.cur_grid_cell) _f.cur_grid_cell.grid.cell_deselect();if(locals[me.doctype][me.docname][me.df.fieldname]&&!val){me.run_trigger();return;} -var fetch='';if(cur_frm.fetch_dict[me.df.fieldname]) +me.validate_link(val,from_selector);} +LinkField.prototype.validate_link=function(val,from_selector){var me=this;var fetch='';if(cur_frm.fetch_dict[me.df.fieldname]) fetch=cur_frm.fetch_dict[me.df.fieldname].columns.join(', ');$c('webnotes.widgets.form.utils.validate_link',{'value':val,'options':me.df.options,'fetch':fetch},function(r,rt){if(r.message=='Ok'){if($(me.txt).val()!=val){if((me.grid&&!from_selector)||(!me.grid)){$(me.txt).val(val);}} if(r.fetch_values) me.set_fetch_values(r.fetch_values);me.run_trigger();}else{var astr='';if(in_list(profile.can_create,me.df.options))astr=repl('

    Click here to create a new %(dtl)s',{dt:me.df.options,dtl:get_doctype_label(me.df.options)}) From 2939a0ea65a761a88289b71e85dddda9954c1771 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Thu, 21 Jun 2012 11:20:37 +0530 Subject: [PATCH 02/13] fetch price list rates when creating quotation from opportunity --- .../selling/doctype/quotation/quotation.js | 3 +-- .../selling/doctype/quotation/quotation.py | 19 +++++++++++++------ 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/erpnext/selling/doctype/quotation/quotation.js b/erpnext/selling/doctype/quotation/quotation.js index e444a668f5..9a45c70091 100644 --- a/erpnext/selling/doctype/quotation/quotation.js +++ b/erpnext/selling/doctype/quotation/quotation.js @@ -50,10 +50,9 @@ cur_frm.cscript.onload = function(doc, cdt, cdn) { } } cur_frm.cscript.make_communication_body(); - } -cur_frm.cscript.onload_post_render = function(doc, dt, dn) { +cur_frm.cscript.onload_post_render = function(doc, dt, dn) { var callback = function(doc, dt, dn) { // defined in sales_common.js cur_frm.cscript.update_item_details(doc, dt, dn); diff --git a/erpnext/selling/doctype/quotation/quotation.py b/erpnext/selling/doctype/quotation/quotation.py index 5756710779..a80fe11bf2 100644 --- a/erpnext/selling/doctype/quotation/quotation.py +++ b/erpnext/selling/doctype/quotation/quotation.py @@ -81,12 +81,19 @@ class DocType(TransactionBase): obj = get_obj('Sales Common') for doc in self.doclist: if doc.fields.get('item_code'): - arg = {'item_code':doc.fields.get('item_code'), 'income_account':doc.fields.get('income_account'), - 'cost_center': doc.fields.get('cost_center'), 'warehouse': doc.fields.get('warehouse')}; - ret = obj.get_item_defaults(arg) - for r in ret: - if not doc.fields.get(r): - doc.fields[r] = ret[r] + arg = { + 'item_code': doc.fields.get('item_code'), + 'income_account': doc.fields.get('income_account'), + 'cost_center': doc.fields.get('cost_center'), + 'warehouse': doc.fields.get('warehouse') + } + fields_dict = obj.get_item_details(arg, self) + if fields_dict: + doc.fields.update(fields_dict) + #ret = obj.get_item_defaults(arg) + #for r in ret: + # if not doc.fields.get(r): + # doc.fields[r] = ret[r] # Re-calculates Basic Rate & amount based on Price List Selected From 8ae5ba9abfca75675e546d4cdc9fc4f56bbe72e5 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Mon, 25 Jun 2012 20:05:35 +0530 Subject: [PATCH 03/13] fixes related to --> clear locals and then sync locals when whole doclist is passed --- .../bank_reconciliation.py | 2 +- .../budget_distribution.js | 2 +- erpnext/accounts/doctype/form_16a/form_16a.py | 4 +-- .../accounts/doctype/gl_control/gl_control.py | 4 ++- .../journal_voucher/journal_voucher.py | 2 +- .../payment_to_invoice_matching_tool.py | 2 +- .../purchase_invoice/purchase_invoice.py | 4 +-- .../doctype/sales_invoice/sales_invoice.py | 11 ++++---- .../doctype/tds_payment/tds_payment.py | 2 +- .../purchase_common/purchase_common.py | 3 ++- .../doctype/purchase_order/purchase_order.py | 4 +-- .../quality_inspection/quality_inspection.py | 2 +- erpnext/hr/doctype/appraisal/appraisal.py | 2 +- .../hr/doctype/holiday_list/holiday_list.py | 2 +- .../leave_control_panel.js | 2 +- erpnext/hr/doctype/salary_slip/salary_slip.py | 4 +-- erpnext/production/doctype/bom/bom.py | 2 +- .../production_planning_tool.py | 4 +-- .../project_activity/project_activity.js | 2 +- erpnext/selling/doctype/lead/lead.js | 4 +-- .../selling/doctype/quotation/quotation.py | 6 ++--- .../doctype/sales_common/sales_common.py | 27 ++++++++++++++----- .../doctype/sales_order/sales_order.py | 17 ++++++------ .../contact_control/contact_control.js | 2 +- .../doctype/naming_series/naming_series.js | 4 +-- .../setup/doctype/price_list/price_list.js | 2 +- .../doctype/sales_person/sales_person.js | 2 +- .../doctype/delivery_note/delivery_note.py | 6 ++--- .../landed_cost_wizard/landed_cost_wizard.py | 4 +-- .../purchase_receipt/purchase_receipt.py | 4 +-- .../sales_and_purchase_return_tool.py | 4 +-- .../stock/doctype/stock_entry/stock_entry.py | 2 +- erpnext/stock/doctype/warehouse/warehouse.js | 2 +- .../maintenance_schedule.py | 6 ++--- .../maintenance_visit/maintenance_visit.py | 2 +- .../doctype/support_ticket/support_ticket.js | 6 ++--- erpnext/utilities/transaction_base.py | 2 +- public/js/all-app.js | 11 +++++--- public/js/all-web.js | 9 ++++--- 39 files changed, 103 insertions(+), 79 deletions(-) diff --git a/erpnext/accounts/doctype/bank_reconciliation/bank_reconciliation.py b/erpnext/accounts/doctype/bank_reconciliation/bank_reconciliation.py index 00bdc47910..2c228a771b 100644 --- a/erpnext/accounts/doctype/bank_reconciliation/bank_reconciliation.py +++ b/erpnext/accounts/doctype/bank_reconciliation/bank_reconciliation.py @@ -44,7 +44,7 @@ class DocType: dl = sql("select t1.name, t1.cheque_no, t1.cheque_date, t2.debit, t2.credit, t1.posting_date, t2.against_account from `tabJournal Voucher` t1, `tabJournal Voucher Detail` t2 where t2.parent = t1.name and t2.account = %s and (clearance_date is null or clearance_date = '0000-00-00' or clearance_date = '') and (t1.cheque_no is not null or t1.cheque_no != '') and t1.posting_date >= %s and t1.posting_date <= %s and t1.docstatus=1", (self.doc.bank_account, self.doc.from_date, self.doc.to_date)) - self.doc.clear_table(self.doclist, 'entries') + self.doclist = self.doc.clear_table(self.doclist, 'entries') self.doc.total_amount = 0.0 for d in dl: diff --git a/erpnext/accounts/doctype/budget_distribution/budget_distribution.js b/erpnext/accounts/doctype/budget_distribution/budget_distribution.js index 84726e8099..d7deb9a712 100644 --- a/erpnext/accounts/doctype/budget_distribution/budget_distribution.js +++ b/erpnext/accounts/doctype/budget_distribution/budget_distribution.js @@ -20,6 +20,6 @@ cur_frm.cscript.onload = function(doc,cdt,cdn){ refresh_field('budget_distribution_details'); } - $c('runserverobj',args={'method' : 'get_months', 'docs' : compress_doclist([doc])},callback1); + $c('runserverobj',args={'method' : 'get_months', 'docs' : compress_doclist(make_doclist(doc.doctype, doc.name))},callback1); } } \ No newline at end of file diff --git a/erpnext/accounts/doctype/form_16a/form_16a.py b/erpnext/accounts/doctype/form_16a/form_16a.py index d847ec55a7..fa2adb1c63 100644 --- a/erpnext/accounts/doctype/form_16a/form_16a.py +++ b/erpnext/accounts/doctype/form_16a/form_16a.py @@ -77,7 +77,7 @@ class DocType(TransactionBase): # Get TDS Return acknowledgement #------------------------------- def get_return_ack_details(self): - self.doc.clear_table(self.doclist, 'form_16A_ack_details') + self.doclist = self.doc.clear_table(self.doclist, 'form_16A_ack_details') if not (self.doc.from_date and self.doc.to_date): msgprint("Please enter From Date, To Date") else: @@ -90,7 +90,7 @@ class DocType(TransactionBase): # Get tds payment details #------------------------------- def get_tds(self): - self.doc.clear_table(self.doclist,'form_16A_tax_details') + self.doclist = self.doc.clear_table(self.doclist,'form_16A_tax_details') import datetime if self.doc.from_date and self.doc.to_date and self.doc.tds_category: tot=0.0 diff --git a/erpnext/accounts/doctype/gl_control/gl_control.py b/erpnext/accounts/doctype/gl_control/gl_control.py index 66a0d65b74..bfeddb0c52 100644 --- a/erpnext/accounts/doctype/gl_control/gl_control.py +++ b/erpnext/accounts/doctype/gl_control/gl_control.py @@ -289,7 +289,7 @@ class DocType: def get_advances(self, obj, account_head, table_name,table_field_name, dr_or_cr): jv_detail = webnotes.conn.sql("select t1.name, t1.remark, t2.%s, t2.name, t1.ded_amount from `tabJournal Voucher` t1, `tabJournal Voucher Detail` t2 where t1.name = t2.parent and (t2.against_voucher is null or t2.against_voucher = '') and (t2.against_invoice is null or t2.against_invoice = '') and (t2.against_jv is null or t2.against_jv = '') and t2.account = '%s' and t2.is_advance = 'Yes' and t1.docstatus = 1 order by t1.voucher_date " % (dr_or_cr,account_head)) # clear advance table - obj.doc.clear_table(obj.doclist,table_field_name) + obj.doclist = obj.doc.clear_table(obj.doclist,table_field_name) # Create advance table for d in jv_detail: add = addchild(obj.doc, table_field_name, table_name, 1, obj.doclist) @@ -300,6 +300,8 @@ class DocType: add.allocate_amount = 0 if table_name == 'Purchase Invoice Advance': add.tds_amount = flt(d[4]) + + return obj.doclist # Clear rows which is not adjusted #------------------------------------- diff --git a/erpnext/accounts/doctype/journal_voucher/journal_voucher.py b/erpnext/accounts/doctype/journal_voucher/journal_voucher.py index 32bd387e02..7fed12929b 100644 --- a/erpnext/accounts/doctype/journal_voucher/journal_voucher.py +++ b/erpnext/accounts/doctype/journal_voucher/journal_voucher.py @@ -378,7 +378,7 @@ class DocType: # get outstanding invoices # ------------------------- def get_outstanding_invoices(self): - self.doc.clear_table(self.doclist, 'entries') + self.doclist = self.doc.clear_table(self.doclist, 'entries') total = 0 for d in self.get_values(): total += flt(d[2]) diff --git a/erpnext/accounts/doctype/payment_to_invoice_matching_tool/payment_to_invoice_matching_tool.py b/erpnext/accounts/doctype/payment_to_invoice_matching_tool/payment_to_invoice_matching_tool.py index 138f3d57bc..d615013d76 100644 --- a/erpnext/accounts/doctype/payment_to_invoice_matching_tool/payment_to_invoice_matching_tool.py +++ b/erpnext/accounts/doctype/payment_to_invoice_matching_tool/payment_to_invoice_matching_tool.py @@ -73,7 +73,7 @@ class DocType: Payment entry will be decided based on account type (Dr/Cr) """ - self.doc.clear_table(self.doclist, 'ir_payment_details') + self.doclist = self.doc.clear_table(self.doclist, 'ir_payment_details') gle = self.get_gl_entries() self.create_payment_table(gle) diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py index f57cfe7c17..668d2ef005 100644 --- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py +++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py @@ -170,7 +170,7 @@ class DocType(TransactionBase): # Advance Allocation # ------------------- def get_advances(self): - get_obj('GL Control').get_advances( self, self.doc.credit_to, 'Purchase Invoice Advance','advance_allocation_details','debit') + self.doclist = get_obj('GL Control').get_advances(self, self.doc.credit_to, 'Purchase Invoice Advance','advance_allocation_details','debit') # ============= OTHER CHARGES ==================== @@ -183,7 +183,7 @@ class DocType(TransactionBase): # Get Purchase Taxes and Charges Master # ----------------------------------------------------------- def get_purchase_tax_details(self): - return get_obj('Purchase Common').get_purchase_tax_details(self) + self.doclist = get_obj('Purchase Common').get_purchase_tax_details(self) def get_rate1(self,acc): diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py index f07c7b3ffc..82314ca133 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py @@ -140,13 +140,13 @@ class DocType(TransactionBase): # Delivery Note if self.doc.delivery_note_main: self.validate_prev_docname('delivery note') - self.doc.clear_table(self.doclist,'other_charges') + self.doclist = self.doc.clear_table(self.doclist,'other_charges') self.doclist = get_obj('DocType Mapper', 'Delivery Note-Sales Invoice').dt_map('Delivery Note', 'Sales Invoice', self.doc.delivery_note_main, self.doc, self.doclist, "[['Delivery Note', 'Sales Invoice'],['Delivery Note Item', 'Sales Invoice Item'],['Sales Taxes and Charges','Sales Taxes and Charges'],['Sales Team','Sales Team']]") self.get_income_account('entries') # Sales Order elif self.doc.sales_order_main: self.validate_prev_docname('sales order') - self.doc.clear_table(self.doclist,'other_charges') + self.doclist = self.doc.clear_table(self.doclist,'other_charges') get_obj('DocType Mapper', 'Sales Order-Sales Invoice').dt_map('Sales Order', 'Sales Invoice', self.doc.sales_order_main, self.doc, self.doclist, "[['Sales Order', 'Sales Invoice'],['Sales Order Item', 'Sales Invoice Item'],['Sales Taxes and Charges','Sales Taxes and Charges'], ['Sales Team', 'Sales Team']]") self.get_income_account('entries') @@ -240,18 +240,17 @@ class DocType(TransactionBase): # Load Default Charges # ---------------------------------------------------------- def load_default_taxes(self): - return get_obj('Sales Common').load_default_taxes(self) + self.doclist = get_obj('Sales Common').load_default_taxes(self) # Get Sales Taxes and Charges Master Details # -------------------------- def get_other_charges(self): - return get_obj('Sales Common').get_other_charges(self) - + self.doclist = get_obj('Sales Common').get_other_charges(self) # Get Advances # ------------- def get_advances(self): - get_obj('GL Control').get_advances(self, self.doc.debit_to, 'Sales Invoice Advance', 'advance_adjustment_details', 'credit') + self.doclist = get_obj('GL Control').get_advances(self, self.doc.debit_to, 'Sales Invoice Advance', 'advance_adjustment_details', 'credit') #pull project customer #------------------------- diff --git a/erpnext/accounts/doctype/tds_payment/tds_payment.py b/erpnext/accounts/doctype/tds_payment/tds_payment.py index 346c565f48..c1874d9f46 100644 --- a/erpnext/accounts/doctype/tds_payment/tds_payment.py +++ b/erpnext/accounts/doctype/tds_payment/tds_payment.py @@ -67,7 +67,7 @@ class DocType: # Fetch voucherwise tds details #------------------------------- def get_tds_list(self): - self.doc.clear_table(self.doclist,'tds_payment_details') + self.doclist = self.doc.clear_table(self.doclist,'tds_payment_details') self.doc.total_tds = 0 import datetime if not self.doc.tds_category: diff --git a/erpnext/buying/doctype/purchase_common/purchase_common.py b/erpnext/buying/doctype/purchase_common/purchase_common.py index e230e0f77b..fd02b02128 100644 --- a/erpnext/buying/doctype/purchase_common/purchase_common.py +++ b/erpnext/buying/doctype/purchase_common/purchase_common.py @@ -621,7 +621,7 @@ class DocType(TransactionBase): # Get other charges from Master # ================================================================================= def get_purchase_tax_details(self,obj): - self.doc.clear_table(obj.doclist,'purchase_tax_details') + obj.doclist = self.doc.clear_table(obj.doclist,'purchase_tax_details') idx = 0 other_charge = sql("select category, add_deduct_tax, charge_type,row_id,description,account_head,rate,tax_amount from `tabPurchase Taxes and Charges` where parent = '%s' order by idx" %(obj.doc.purchase_other_charges), as_dict = 1) for other in other_charge: @@ -636,6 +636,7 @@ class DocType(TransactionBase): d.tax_amount = flt(other['tax_amount']) d.idx = idx idx += 1 + return obj.doclist # Get Tax rate if account type is TAX diff --git a/erpnext/buying/doctype/purchase_order/purchase_order.py b/erpnext/buying/doctype/purchase_order/purchase_order.py index f3bd8b508c..9b7e99c26f 100644 --- a/erpnext/buying/doctype/purchase_order/purchase_order.py +++ b/erpnext/buying/doctype/purchase_order/purchase_order.py @@ -291,7 +291,7 @@ class DocType(TransactionBase): if self.doc.is_subcontracted == 'Yes': self.add_bom(d) else: - self.doc.clear_table(self.doclist,'po_raw_material_details',1) + self.doclist = self.doc.clear_table(self.doclist,'po_raw_material_details',1) self.doc.save() elif item_det[0][1] == 'No': self.add_bom(d) @@ -371,4 +371,4 @@ class DocType(TransactionBase): # **** Pull details from other charges master (Get Other Charges) **** def get_purchase_tax_details(self): - return get_obj('Purchase Common').get_purchase_tax_details(self) + self.doclist = get_obj('Purchase Common').get_purchase_tax_details(self) diff --git a/erpnext/buying/doctype/quality_inspection/quality_inspection.py b/erpnext/buying/doctype/quality_inspection/quality_inspection.py index 48ab1129d3..1519268078 100644 --- a/erpnext/buying/doctype/quality_inspection/quality_inspection.py +++ b/erpnext/buying/doctype/quality_inspection/quality_inspection.py @@ -45,7 +45,7 @@ class DocType: def get_item_specification_details(self): - self.doc.clear_table(self.doclist, 'qa_specification_details') + self.doclist = self.doc.clear_table(self.doclist, 'qa_specification_details') specification = sql("select specification, value from `tabItem Quality Inspection Parameter` where parent = '%s' order by idx" % (self.doc.item_code)) for d in specification: child = addchild(self.doc, 'qa_specification_details', 'Quality Inspection Reading', 1, self.doclist) diff --git a/erpnext/hr/doctype/appraisal/appraisal.py b/erpnext/hr/doctype/appraisal/appraisal.py index f46427ca39..a889e5fa6a 100644 --- a/erpnext/hr/doctype/appraisal/appraisal.py +++ b/erpnext/hr/doctype/appraisal/appraisal.py @@ -48,7 +48,7 @@ class DocType: if not self.doc.kra_template: msgprint("Please select Appraisal Template to be be fetched") raise Exception - self.doc.clear_table(self.doclist,'appraisal_details') + self.doclist = self.doc.clear_table(self.doclist,'appraisal_details') get_obj('DocType Mapper', 'Appraisal Template-Appraisal').dt_map('Appraisal Template', 'Appraisal', self.doc.kra_template, self.doc, self.doclist, "[['Appraisal Template','Appraisal'],['Appraisal Template Goal', 'Appraisal Goal']]") def validate_dates(self): diff --git a/erpnext/hr/doctype/holiday_list/holiday_list.py b/erpnext/hr/doctype/holiday_list/holiday_list.py index 77bdb1f078..78c9e33cea 100644 --- a/erpnext/hr/doctype/holiday_list/holiday_list.py +++ b/erpnext/hr/doctype/holiday_list/holiday_list.py @@ -113,7 +113,7 @@ class DocType: # clear table # ------------ def clear_table(self): - self.doc.clear_table(self.doclist,'holiday_list_details') + self.doclist = self.doc.clear_table(self.doclist,'holiday_list_details') # ***************************************** validate ************************************************* diff --git a/erpnext/hr/doctype/leave_control_panel/leave_control_panel.js b/erpnext/hr/doctype/leave_control_panel/leave_control_panel.js index 54cc8d5835..67fe9b547b 100644 --- a/erpnext/hr/doctype/leave_control_panel/leave_control_panel.js +++ b/erpnext/hr/doctype/leave_control_panel/leave_control_panel.js @@ -24,7 +24,7 @@ cur_frm.cscript.onload = function(doc,dt,dn){ // Validation For To Date // ================================================================================================ cur_frm.cscript.to_date = function(doc, cdt, cdn) { - $c('runserverobj', args={'method':'to_date_validation','docs':compress_doclist([doc])}, + $c('runserverobj', args={'method':'to_date_validation','docs':compress_doclist(make_doclist(doc.doctype, doc.name))}, function(r, rt) { var doc = locals[cdt][cdn]; if (r.message) { diff --git a/erpnext/hr/doctype/salary_slip/salary_slip.py b/erpnext/hr/doctype/salary_slip/salary_slip.py index c041e48b18..3439fc861f 100644 --- a/erpnext/hr/doctype/salary_slip/salary_slip.py +++ b/erpnext/hr/doctype/salary_slip/salary_slip.py @@ -70,8 +70,8 @@ class DocType(TransactionBase): # Pull struct details #======================================================= def pull_sal_struct(self, struct): - self.doc.clear_table(self.doclist, 'earning_details') - self.doc.clear_table(self.doclist, 'deduction_details') + self.doclist = self.doc.clear_table(self.doclist, 'earning_details') + self.doclist = self.doc.clear_table(self.doclist, 'deduction_details') get_obj('DocType Mapper', 'Salary Structure-Salary Slip').dt_map('Salary Structure', 'Salary Slip', struct, self.doc, self.doclist, "[['Salary Structure', 'Salary Slip'],['Salary Structure Earning', 'Salary Slip Earning'],['Salary Structure Deduction','Salary Slip Deduction']]") diff --git a/erpnext/production/doctype/bom/bom.py b/erpnext/production/doctype/bom/bom.py index 36df84e442..81297b4f1b 100644 --- a/erpnext/production/doctype/bom/bom.py +++ b/erpnext/production/doctype/bom/bom.py @@ -322,7 +322,7 @@ class DocType: def add_to_flat_bom_detail(self, is_submit = 0): "Add items to Flat BOM table" - self.doc.clear_table(self.doclist, 'flat_bom_details', 1) + self.doclist = self.doc.clear_table(self.doclist, 'flat_bom_details', 1) for d in self.cur_flat_bom_items: ch = addchild(self.doc, 'flat_bom_details', 'BOM Explosion Item', 1, self.doclist) for i in d.keys(): diff --git a/erpnext/production/doctype/production_planning_tool/production_planning_tool.py b/erpnext/production/doctype/production_planning_tool/production_planning_tool.py index d910a20460..21ef599e4d 100644 --- a/erpnext/production/doctype/production_planning_tool/production_planning_tool.py +++ b/erpnext/production/doctype/production_planning_tool/production_planning_tool.py @@ -58,13 +58,13 @@ class DocType: def clear_so_table(self): """ Clears sales order table""" - self.doc.clear_table(self.doclist, 'pp_so_details') + self.doclist = self.doc.clear_table(self.doclist, 'pp_so_details') def clear_item_table(self): """ Clears item table""" - self.doc.clear_table(self.doclist, 'pp_details') + self.doclist = self.doc.clear_table(self.doclist, 'pp_details') diff --git a/erpnext/projects/doctype/project_activity/project_activity.js b/erpnext/projects/doctype/project_activity/project_activity.js index 46531b74b4..ad33e3cd7f 100644 --- a/erpnext/projects/doctype/project_activity/project_activity.js +++ b/erpnext/projects/doctype/project_activity/project_activity.js @@ -95,5 +95,5 @@ cur_frm.cscript.add = function(doc, dt, dn) { cur_frm.mylist.run(); } - $c_obj([doc],'add_update','',callback); + $c_obj(make_doclist(doc.doctype, doc.name),'add_update','',callback); } diff --git a/erpnext/selling/doctype/lead/lead.js b/erpnext/selling/doctype/lead/lead.js index 389dce0db1..57f2bee185 100644 --- a/erpnext/selling/doctype/lead/lead.js +++ b/erpnext/selling/doctype/lead/lead.js @@ -87,7 +87,7 @@ cur_frm.cscript.item_code=function(doc,cdt,cdn){ // =============================================================== cur_frm.cscript['Create Customer'] = function(){ var doc = cur_frm.doc; - $c('runserverobj',args={ 'method':'check_status', 'docs':compress_doclist([doc])}, + $c('runserverobj',args={ 'method':'check_status', 'docs':compress_doclist(make_doclist(doc.doctype, doc.name))}, function(r,rt){ if(r.message == 'Converted'){ msgprint("This lead is already converted to customer"); @@ -124,7 +124,7 @@ cur_frm.cscript.send_email = function(doc,cdt,cdn){ // =============================================================== cur_frm.cscript['Create Opportunity'] = function(){ var doc = cur_frm.doc; - $c('runserverobj',args={ 'method':'check_status', 'docs':compress_doclist([doc])}, + $c('runserverobj',args={ 'method':'check_status', 'docs':compress_doclist(make_doclist(doc.doctype, doc.name))}, function(r,rt){ if(r.message == 'Converted'){ msgprint("This lead is now converted to customer. Please create enquiry on behalf of customer"); diff --git a/erpnext/selling/doctype/quotation/quotation.py b/erpnext/selling/doctype/quotation/quotation.py index a80fe11bf2..c0306e8154 100644 --- a/erpnext/selling/doctype/quotation/quotation.py +++ b/erpnext/selling/doctype/quotation/quotation.py @@ -53,7 +53,7 @@ class DocType(TransactionBase): # Pull Opportunity Details # -------------------- def pull_enq_details(self): - self.doc.clear_table(self.doclist, 'quotation_details') + self.doclist = self.doc.clear_table(self.doclist, 'quotation_details') get_obj('DocType Mapper', 'Opportunity-Quotation').dt_map('Opportunity', 'Quotation', self.doc.enq_no, self.doc, self.doclist, "[['Opportunity', 'Quotation'],['Opportunity Item', 'Quotation Item']]") self.get_adj_percent() @@ -115,12 +115,12 @@ class DocType(TransactionBase): # Load Default Charges # ---------------------------------------------------------- def load_default_taxes(self): - return get_obj('Sales Common').load_default_taxes(self) + self.doclist = get_obj('Sales Common').load_default_taxes(self) # Pull details from other charges master (Get Sales Taxes and Charges Master) # ---------------------------------------------------------- def get_other_charges(self): - return get_obj('Sales Common').get_other_charges(self) + self.doclist = get_obj('Sales Common').get_other_charges(self) # GET TERMS AND CONDITIONS diff --git a/erpnext/selling/doctype/sales_common/sales_common.py b/erpnext/selling/doctype/sales_common/sales_common.py index f942a2f0f6..fdd7013dad 100644 --- a/erpnext/selling/doctype/sales_common/sales_common.py +++ b/erpnext/selling/doctype/sales_common/sales_common.py @@ -72,9 +72,11 @@ class DocType(TransactionBase): # Get Sales Person Details # ========================== + + # TODO: To be deprecated if not in use def get_sales_person_details(self, obj): if obj.doc.doctype != 'Quotation': - obj.doc.clear_table(obj.doclist,'sales_team') + obj.doclist = obj.doc.clear_table(obj.doclist,'sales_team') idx = 0 for d in webnotes.conn.sql("select sales_person, allocated_percentage, allocated_amount, incentives from `tabSales Team` where parent = '%s'" % obj.doc.customer): ch = addchild(obj.doc, 'sales_team', 'Sales Team', 1, obj.doclist) @@ -84,6 +86,7 @@ class DocType(TransactionBase): ch.incentives = d and flt(d[3]) or 0 ch.idx = idx idx += 1 + return obj.doclist # Get customer's contact person details @@ -215,15 +218,15 @@ class DocType(TransactionBase): # ==================== def load_default_taxes(self, obj): if cstr(obj.doc.charge): - self.get_other_charges(obj) + return self.get_other_charges(obj) else: - self.get_other_charges(obj, 1) + return self.get_other_charges(obj, 1) # Get other charges from Master # ================================================================================= def get_other_charges(self,obj, default=0): - obj.doc.clear_table(obj.doclist,'other_charges') + obj.doclist = obj.doc.clear_table(obj.doclist, 'other_charges') if not getlist(obj.doclist, 'other_charges'): if default: add_cond = 'ifnull(t2.is_default,0) = 1' else: add_cond = 't1.parent = "'+cstr(obj.doc.charge)+'"' @@ -253,6 +256,7 @@ class DocType(TransactionBase): d.included_in_print_rate = cint(d.included_in_print_rate) d.idx = idx idx += 1 + return obj.doclist # Get TERMS AND CONDITIONS # ======================================================================================= @@ -484,11 +488,22 @@ class DocType(TransactionBase): self.cleanup_packing_list(obj, parent_items) def cleanup_packing_list(self, obj, parent_items): - """Remove all those parent items which are no longer present in main item table""" + """Remove all those child items which are no longer present in main item table""" + delete_list = [] for d in getlist(obj.doclist, 'packing_details'): if [d.parent_item, d.parent_detail_docname] not in parent_items: - d.parent = '' + # mark for deletion from doclist + delete_list.append(d.name) + if not delete_list: return + + # delete from doclist + obj.doclist = filter(lambda d: d.name not in delete_list, obj.doclist) + + # delete from db + webnotes.conn.sql("""\ + delete from `tabDelivery Note Packing Item` + where name in ("%s")""" % '", "'.join(delete_list)) # Get total in words # ================================================================== diff --git a/erpnext/selling/doctype/sales_order/sales_order.py b/erpnext/selling/doctype/sales_order/sales_order.py index 660a288c25..9cb1b4a781 100644 --- a/erpnext/selling/doctype/sales_order/sales_order.py +++ b/erpnext/selling/doctype/sales_order/sales_order.py @@ -35,8 +35,9 @@ convert_to_lists = webnotes.conn.convert_to_lists from utilities.transaction_base import TransactionBase class DocType(TransactionBase): - def __init__(self, doc, doclist=[]): + def __init__(self, doc, doclist=None): self.doc = doc + if not doclist: doclist = [] self.doclist = doclist self.tname = 'Sales Order Item' self.fname = 'sales_order_details' @@ -55,10 +56,10 @@ class DocType(TransactionBase): # Pull Quotation Items # ----------------------- def pull_quotation_details(self): - self.doc.clear_table(self.doclist, 'other_charges') - self.doc.clear_table(self.doclist, 'sales_order_details') - self.doc.clear_table(self.doclist, 'sales_team') - self.doc.clear_table(self.doclist, 'tc_details') + self.doclist = self.doc.clear_table(self.doclist, 'other_charges') + self.doclist = self.doc.clear_table(self.doclist, 'sales_order_details') + self.doclist = self.doc.clear_table(self.doclist, 'sales_team') + self.doclist = self.doc.clear_table(self.doclist, 'tc_details') if self.doc.quotation_no: get_obj('DocType Mapper', 'Quotation-Sales Order').dt_map('Quotation', 'Sales Order', self.doc.quotation_no, self.doc, self.doclist, "[['Quotation', 'Sales Order'],['Quotation Item', 'Sales Order Item'],['Sales Taxes and Charges','Sales Taxes and Charges'],['Sales Team','Sales Team'],['TC Detail','TC Detail']]") else: @@ -135,12 +136,12 @@ class DocType(TransactionBase): # Load Default Charges # ---------------------------------------------------------- def load_default_taxes(self): - return get_obj('Sales Common').load_default_taxes(self) + self.doclist = get_obj('Sales Common').load_default_taxes(self) # Pull details from other charges master (Get Sales Taxes and Charges Master) # ---------------------------------------------------------- def get_other_charges(self): - return get_obj('Sales Common').get_other_charges(self) + self.doclist = get_obj('Sales Common').get_other_charges(self) # GET TERMS & CONDITIONS @@ -322,7 +323,7 @@ class DocType(TransactionBase): # this is to verify that the allocated % of sales persons is 100% sales_com_obj.get_allocated_sum(self) sales_com_obj.make_packing_list(self,'sales_order_details') - + # get total in words dcc = TransactionBase().get_company_currency(self.doc.company) self.doc.in_words = sales_com_obj.get_total_in_words(dcc, self.doc.rounded_total) diff --git a/erpnext/setup/doctype/contact_control/contact_control.js b/erpnext/setup/doctype/contact_control/contact_control.js index 1d17244443..a07fd832be 100755 --- a/erpnext/setup/doctype/contact_control/contact_control.js +++ b/erpnext/setup/doctype/contact_control/contact_control.js @@ -55,7 +55,7 @@ cur_frm.cscript.make_history_list = function(parent,doc){ // get sates on country trigger // ----------------------------- cur_frm.cscript.get_states=function(doc,dt,dn){ - $c('runserverobj', args={'method':'check_state', 'docs':compress_doclist([doc])}, + $c('runserverobj', args={'method':'check_state', 'docs':compress_doclist(make_doclist(doc.doctype, doc.name))}, function(r,rt){ if(r.message) { set_field_options('state', r.message); diff --git a/erpnext/setup/doctype/naming_series/naming_series.js b/erpnext/setup/doctype/naming_series/naming_series.js index c7897e44f5..7e702c45f4 100644 --- a/erpnext/setup/doctype/naming_series/naming_series.js +++ b/erpnext/setup/doctype/naming_series/naming_series.js @@ -19,7 +19,7 @@ cur_frm.cscript.onload = function(doc, cdt, cdn){ var callback = function(r, rt){ set_field_options('select_doc_for_series', r.message); } - $c_obj([doc],'get_transactions','',callback); + $c_obj(make_doclist(doc.doctype, doc.name),'get_transactions','',callback); cur_frm.cscript.refresh(); // add page head //var ph = new PageHeader(cur_frm.fields_dict['head_html'].wrapper, 'Setup Series', 'Set prefix for numbering series on your transactions'); @@ -36,5 +36,5 @@ cur_frm.cscript.select_doc_for_series = function(doc, cdt, cdn) { refresh_field('set_options'); } - $c_obj([doc],'get_options','',callback) + $c_obj(make_doclist(doc.doctype, doc.name),'get_options','',callback) } diff --git a/erpnext/setup/doctype/price_list/price_list.js b/erpnext/setup/doctype/price_list/price_list.js index 9b7f741878..a222a65f08 100644 --- a/erpnext/setup/doctype/price_list/price_list.js +++ b/erpnext/setup/doctype/price_list/price_list.js @@ -32,6 +32,6 @@ cur_frm.cscript.refresh = function(doc, cdt, cdn) { cur_frm.cscript.clear_prices = function(doc, cdt, cdn) { if(confirm("This action will clear all rates for '"+ doc.name +"' from the Item Master and cannot be un-done. Are you sure you want to continue?")) { - $c_obj([doc], 'clear_prices', '', function(r, rt) { }); + $c_obj(make_doclist(doc.doctype, doc.name), 'clear_prices', '', function(r, rt) { }); } } diff --git a/erpnext/setup/doctype/sales_person/sales_person.js b/erpnext/setup/doctype/sales_person/sales_person.js index b0419bd871..453d88a454 100644 --- a/erpnext/setup/doctype/sales_person/sales_person.js +++ b/erpnext/setup/doctype/sales_person/sales_person.js @@ -26,7 +26,7 @@ cur_frm.cscript.onload = function(){ } cur_frm.cscript.country = function(doc, cdt, cdn) { var mydoc=doc; - $c('runserverobj', args={'method':'check_state', 'docs':compress_doclist([doc])}, + $c('runserverobj', args={'method':'check_state', 'docs':compress_doclist(make_doclist(doc.doctype, doc.name))}, function(r,rt){ if(r.message) { var doc = locals[mydoc.doctype][mydoc.name]; diff --git a/erpnext/stock/doctype/delivery_note/delivery_note.py b/erpnext/stock/doctype/delivery_note/delivery_note.py index 9c640f4d3c..5d551bb9a1 100644 --- a/erpnext/stock/doctype/delivery_note/delivery_note.py +++ b/erpnext/stock/doctype/delivery_note/delivery_note.py @@ -65,7 +65,7 @@ class DocType(TransactionBase): # *************** Pull Sales Order Items ************************ def pull_sales_order_details(self): self.validate_prev_docname() - self.doc.clear_table(self.doclist,'other_charges') + self.doclist = self.doc.clear_table(self.doclist,'other_charges') if self.doc.sales_order_no: get_obj('DocType Mapper', 'Sales Order-Delivery Note').dt_map('Sales Order', 'Delivery Note', self.doc.sales_order_no, self.doc, self.doclist, "[['Sales Order', 'Delivery Note'],['Sales Order Item', 'Delivery Note Item'],['Sales Taxes and Charges','Sales Taxes and Charges'],['Sales Team','Sales Team']]") @@ -151,12 +151,12 @@ class DocType(TransactionBase): # Load Default Charges # ---------------------------------------------------------- def load_default_taxes(self): - return get_obj('Sales Common').load_default_taxes(self) + self.doclist = get_obj('Sales Common').load_default_taxes(self) # **** Pull details from other charges master (Get Sales Taxes and Charges Master) **** def get_other_charges(self): - return get_obj('Sales Common').get_other_charges(self) + self.doclist = get_obj('Sales Common').get_other_charges(self) #check in manage account if sales order required or not. diff --git a/erpnext/stock/doctype/landed_cost_wizard/landed_cost_wizard.py b/erpnext/stock/doctype/landed_cost_wizard/landed_cost_wizard.py index 6123ac28b9..c2df6c1a71 100644 --- a/erpnext/stock/doctype/landed_cost_wizard/landed_cost_wizard.py +++ b/erpnext/stock/doctype/landed_cost_wizard/landed_cost_wizard.py @@ -43,7 +43,7 @@ class DocType: def get_purchase_receipts(self): """ Get purchase receipts for given period """ - self.doc.clear_table(self.doclist,'lc_pr_details',1) + self.doclist = self.doc.clear_table(self.doclist,'lc_pr_details',1) self.check_mandatory() pr = sql("select name from `tabPurchase Receipt` where docstatus = 1 and posting_date >= '%s' and posting_date <= '%s' and currency = '%s' order by name " % (self.doc.from_pr_date, self.doc.to_pr_date, self.doc.currency), as_dict = 1) @@ -58,7 +58,7 @@ class DocType: def get_landed_cost_master_details(self): """ pull details from landed cost master""" - self.doc.clear_table(self.doclist, 'landed_cost_details') + self.doclist = self.doc.clear_table(self.doclist, 'landed_cost_details') idx = 0 landed_cost = sql("select account_head, description from `tabLanded Cost Master Detail` where parent=%s", (self.doc.landed_cost), as_dict = 1) for cost in landed_cost: diff --git a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py index f6ff505b18..10fecbfe66 100644 --- a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py +++ b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py @@ -370,7 +370,7 @@ class DocType(TransactionBase): raise Exception self.add_bom(d) else: - self.doc.clear_table(self.doclist,'pr_raw_material_details',1) + self.doclist = self.doc.clear_table(self.doclist,'pr_raw_material_details',1) self.doc.save() elif item_det[0][1] == 'No': if not self.doc.supplier_warehouse: @@ -479,4 +479,4 @@ class DocType(TransactionBase): # **** Pull details from other charges master (Get Other Charges) **** def get_purchase_tax_details(self): - return get_obj('Purchase Common').get_purchase_tax_details(self) + self.doclist = get_obj('Purchase Common').get_purchase_tax_details(self) diff --git a/erpnext/stock/doctype/sales_and_purchase_return_tool/sales_and_purchase_return_tool.py b/erpnext/stock/doctype/sales_and_purchase_return_tool/sales_and_purchase_return_tool.py index 414198a1cb..00319bdfee 100644 --- a/erpnext/stock/doctype/sales_and_purchase_return_tool/sales_and_purchase_return_tool.py +++ b/erpnext/stock/doctype/sales_and_purchase_return_tool/sales_and_purchase_return_tool.py @@ -57,7 +57,7 @@ class DocType : # Create Item Table # ----------------------------- def create_item_table(self, det): - self.doc.clear_table(self.doclist, 'return_details', 1) + self.doclist = self.doc.clear_table(self.doclist, 'return_details', 1) for i in det: ch = addchild(self.doc, 'return_details', 'Sales and Purchase Return Item', 1, self.doclist) ch.detail_name = i and i[0] or '' @@ -73,5 +73,5 @@ class DocType : # Clear return table # -------------------------------- def clear_return_table(self): - self.doc.clear_table(self.doclist, 'return_details', 1) + self.doclist = self.doc.clear_table(self.doclist, 'return_details', 1) self.doc.save() diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.py b/erpnext/stock/doctype/stock_entry/stock_entry.py index dd6588a166..1cc49f825b 100644 --- a/erpnext/stock/doctype/stock_entry/stock_entry.py +++ b/erpnext/stock/doctype/stock_entry/stock_entry.py @@ -240,7 +240,7 @@ class DocType(TransactionBase): consider_sa_items_as_rm = self.doc.consider_sa_items_as_raw_materials self.get_raw_materials(bom_no, fg_qty, consider_sa_items_as_rm) - self.doc.clear_table(self.doclist, 'mtn_details', 1) + self.doclist = self.doc.clear_table(self.doclist, 'mtn_details', 1) sw = (self.doc.process == 'Backflush') and cstr(pro_obj.doc.wip_warehouse) or '' tw = (self.doc.process == 'Material Transfer') and cstr(pro_obj.doc.wip_warehouse) or '' diff --git a/erpnext/stock/doctype/warehouse/warehouse.js b/erpnext/stock/doctype/warehouse/warehouse.js index cf0d4a0ba4..b218063b4a 100644 --- a/erpnext/stock/doctype/warehouse/warehouse.js +++ b/erpnext/stock/doctype/warehouse/warehouse.js @@ -16,7 +16,7 @@ cur_frm.cscript.country = function(doc, cdt, cdn) { var mydoc=doc; - $c('runserverobj', args={'method':'check_state', 'docs':compress_doclist([doc])}, + $c('runserverobj', args={'method':'check_state', 'docs':compress_doclist(make_doclist(doc.doctype, doc.name))}, function(r,rt){ if(r.message) { var doc = locals[mydoc.doctype][mydoc.name]; diff --git a/erpnext/support/doctype/maintenance_schedule/maintenance_schedule.py b/erpnext/support/doctype/maintenance_schedule/maintenance_schedule.py index 27ec01e5e5..9ad9eb9965 100644 --- a/erpnext/support/doctype/maintenance_schedule/maintenance_schedule.py +++ b/erpnext/support/doctype/maintenance_schedule/maintenance_schedule.py @@ -42,8 +42,8 @@ class DocType(TransactionBase): # pull sales order details #-------------------------- def pull_sales_order_detail(self): - self.doc.clear_table(self.doclist, 'item_maintenance_detail') - self.doc.clear_table(self.doclist, 'maintenance_schedule_detail') + self.doclist = self.doc.clear_table(self.doclist, 'item_maintenance_detail') + self.doclist = self.doc.clear_table(self.doclist, 'maintenance_schedule_detail') self.doclist = get_obj('DocType Mapper', 'Sales Order-Maintenance Schedule').dt_map('Sales Order', 'Maintenance Schedule', self.doc.sales_order_no, self.doc, self.doclist, "[['Sales Order', 'Maintenance Schedule'],['Sales Order Item', 'Maintenance Schedule Item']]") #pull item details @@ -60,7 +60,7 @@ class DocType(TransactionBase): #------------------------------------- def generate_schedule(self): import datetime - self.doc.clear_table(self.doclist, 'maintenance_schedule_detail') + self.doclist = self.doc.clear_table(self.doclist, 'maintenance_schedule_detail') count = 0 sql("delete from `tabMaintenance Schedule Detail` where parent='%s'" %(self.doc.name)) for d in getlist(self.doclist, 'item_maintenance_detail'): diff --git a/erpnext/support/doctype/maintenance_visit/maintenance_visit.py b/erpnext/support/doctype/maintenance_visit/maintenance_visit.py index 70b39eca95..fd0c414de6 100644 --- a/erpnext/support/doctype/maintenance_visit/maintenance_visit.py +++ b/erpnext/support/doctype/maintenance_visit/maintenance_visit.py @@ -56,7 +56,7 @@ class DocType(TransactionBase): msgprint("You can not fetch details of both, Sales Order and Customer Issue, in same Maintenance Visit") raise Exception - self.doc.clear_table(self.doclist, 'maintenance_visit_details') + self.doclist = self.doc.clear_table(self.doclist, 'maintenance_visit_details') if self.doc.sales_order_no: self.doclist = get_obj('DocType Mapper', 'Sales Order-Maintenance Visit').dt_map('Sales Order', 'Maintenance Visit', self.doc.sales_order_no, self.doc, self.doclist, "[['Sales Order', 'Maintenance Visit'],['Sales Order Item', 'Maintenance Visit Purpose']]") diff --git a/erpnext/support/doctype/support_ticket/support_ticket.js b/erpnext/support/doctype/support_ticket/support_ticket.js index 48c80b5864..c9c9ea1e52 100644 --- a/erpnext/support/doctype/support_ticket/support_ticket.js +++ b/erpnext/support/doctype/support_ticket/support_ticket.js @@ -99,7 +99,7 @@ $.extend(cur_frm.cscript, { }, send: function(doc, dt, dn) { - $c_obj([doc], 'send_response', '', function(r,rt) { + $c_obj(make_doclist(doc.doctype, doc.name), 'send_response', '', function(r,rt) { locals[dt][dn].new_response = ''; if(!(r.exc || r.server_messages)) { cur_frm.refresh(); @@ -124,7 +124,7 @@ $.extend(cur_frm.cscript, { var answer = confirm("Close Ticket "+doc.name+"?\n\nAllocated To: "+doc.allocated_to+"\n\nSubject: "+doc.subject+""); if(answer) { if(doc.name) - $c_obj([doc],'close_ticket','',function(r,rt) { + $c_obj(make_doclist(doc.doctype, doc.name),'close_ticket','',function(r,rt) { if(!r.exc) { cur_frm.refresh(); } @@ -138,7 +138,7 @@ $.extend(cur_frm.cscript, { var answer = confirm("Re-Open Ticket "+doc.name+"?\n\nAllocated To: "+doc.allocated_to+"\n\nSubject: "+doc.subject+""); if(answer) { if(doc.name) - $c_obj([doc],'reopen_ticket','',function(r,rt) { + $c_obj(make_doclist(doc.doctype, doc.name),'reopen_ticket','',function(r,rt) { if(!r.exc) { cur_frm.refresh(); } diff --git a/erpnext/utilities/transaction_base.py b/erpnext/utilities/transaction_base.py index 2a0183af84..88ed82325e 100644 --- a/erpnext/utilities/transaction_base.py +++ b/erpnext/utilities/transaction_base.py @@ -214,7 +214,7 @@ class TransactionBase: # Get Sales Person Details of Customer # ------------------------------------ def get_sales_person(self, name): - self.doc.clear_table(self.doclist,'sales_team') + self.doclist = self.doc.clear_table(self.doclist,'sales_team') idx = 0 for d in webnotes.conn.sql("select sales_person, allocated_percentage, allocated_amount, incentives from `tabSales Team` where parent = '%s'" % name): ch = addchild(self.doc, 'sales_team', 'Sales Team', 1, self.doclist) diff --git a/public/js/all-app.js b/public/js/all-app.js index 5c736f7d6f..1e4fead58b 100644 --- a/public/js/all-app.js +++ b/public/js/all-app.js @@ -396,7 +396,7 @@ wn.request.cleanup=function(opts,r){if(opts.btn)$(opts.btn).done_working();if(op return;} if(r.server_messages)msgprint(r.server_messages) if(r.exc){console.log(r.exc);};if(r['403']){wn.container.change_to('403');} -if(r.docs)LocalDB.sync(r.docs);} +if(r.docs){LocalDB.sync(r.docs);}} wn.request.call=function(opts){wn.request.prepare(opts);$.ajax({url:opts.url||wn.request.url,data:opts.args,type:opts.type||'POST',dataType:opts.dataType||'json',success:function(r,xhr){wn.request.cleanup(opts,r);opts.success(r,xhr.responseText);},error:function(xhr,textStatus){wn.request.cleanup(opts,{});show_alert('Unable to complete request: '+textStatus) if(opts.error)opts.error(xhr)}})} wn.call=function(opts){var args=$.extend({},opts.args) @@ -1313,8 +1313,10 @@ LocalDB.add=function(dt,dn){if(!locals[dt])locals[dt]={};if(locals[dt][dn])delet LocalDB.delete_doc=function(dt,dn){var doc=get_local(dt,dn);for(var ndt in locals){if(locals[ndt]){for(var ndn in locals[ndt]){var doc=locals[ndt][ndn];if(doc&&doc.parenttype==dt&&(doc.parent==dn||doc.__oldparent==dn)){delete locals[ndt][ndn];}}}} delete locals[dt][dn];} function get_local(dt,dn){return locals[dt]?locals[dt][dn]:null;} -LocalDB.sync=function(list){if(list._kl)list=expand_doclist(list);for(var i=0;i Date: Tue, 26 Jun 2012 12:15:15 +0530 Subject: [PATCH 04/13] delete records in child table where parent is missing or parent is like old_par% --- .../june_2012/delete_old_parent_entries.py | 17 +++++++++++++++++ erpnext/patches/patch_list.py | 5 +++++ 2 files changed, 22 insertions(+) create mode 100644 erpnext/patches/june_2012/delete_old_parent_entries.py diff --git a/erpnext/patches/june_2012/delete_old_parent_entries.py b/erpnext/patches/june_2012/delete_old_parent_entries.py new file mode 100644 index 0000000000..c74f609e0b --- /dev/null +++ b/erpnext/patches/june_2012/delete_old_parent_entries.py @@ -0,0 +1,17 @@ +def execute(): + """delete entries of child table having parent like old_par%% or ''""" + import webnotes + res = webnotes.conn.sql("""\ + select dt.name from `tabDocType` dt + where ifnull(dt.istable, 0)=1 and + exists ( + select * from `tabDocField` df + where df.fieldtype='Table' and + df.options=dt.name + )""") + for r in res: + if r[0]: + webnotes.conn.sql("""\ + delete from `tab%s` + where (ifnull(parent, '')='' or parent like "old_par%%") and + ifnull(parenttype, '')!=''""" % r[0]) \ No newline at end of file diff --git a/erpnext/patches/patch_list.py b/erpnext/patches/patch_list.py index 03c0f27dd6..5e5f4c9800 100644 --- a/erpnext/patches/patch_list.py +++ b/erpnext/patches/patch_list.py @@ -452,4 +452,9 @@ patch_list = [ 'patch_file': 'alter_tabsessions', 'description': "alter tabsessions to change user column definition" }, + { + 'patch_module': 'patches.june_2012', + 'patch_file': 'delete_old_parent_entries', + 'description': "delete entries of child table having parent like old_par%% or ''" + }, ] \ No newline at end of file From 0afab07a1f07a4ce2eaf9475ebd4fa2760f778f4 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Thu, 28 Jun 2012 12:59:33 +0530 Subject: [PATCH 05/13] communication listview - show pretty date --- .../doctype/communication/communication.js | 4 ++-- .../support/doctype/communication/listview.js | 4 ++-- public/js/all-app.js | 19 +++++++++---------- 3 files changed, 13 insertions(+), 14 deletions(-) diff --git a/erpnext/support/doctype/communication/communication.js b/erpnext/support/doctype/communication/communication.js index 9b7b896a7b..d6af592048 100644 --- a/erpnext/support/doctype/communication/communication.js +++ b/erpnext/support/doctype/communication/communication.js @@ -36,7 +36,7 @@ cur_frm.cscript.render_communication_list = function(doc, dt, dn) { prepare_data: function(data) { this._super(data); - data.creation = wn.datetime.str_to_user(data.communication_date); + this.prepare_when(data, data.creation); // escape double quote data.content = cstr(data.subject).replace(/"/gi, '\"') @@ -54,7 +54,7 @@ cur_frm.cscript.render_communication_list = function(doc, dt, dn) { {width: '15%', content: 'name'}, {width: '15%', content: 'category'}, {width: '55%', content: 'content'}, - {width: '12%', content:'communication_date', + {width: '12%', content:'when', css: {'text-align': 'right', 'color':'#777'}} ], diff --git a/erpnext/support/doctype/communication/listview.js b/erpnext/support/doctype/communication/listview.js index a15cd8930f..04346f90de 100644 --- a/erpnext/support/doctype/communication/listview.js +++ b/erpnext/support/doctype/communication/listview.js @@ -13,7 +13,7 @@ wn.doclistviews['Communication'] = wn.views.ListView.extend({ prepare_data: function(data) { this._super(data); - data.creation = wn.datetime.only_date(data.creation); + this.prepare_when(data, data.creation); // escape double quote data.content = cstr(data.subject).replace(/"/gi, '\"') @@ -31,7 +31,7 @@ wn.doclistviews['Communication'] = wn.views.ListView.extend({ {width: '15%', content: 'name'}, {width: '15%', content: 'category'}, {width: '55%', content: 'content+tags'}, - {width: '12%', content:'creation', + {width: '12%', content:'when', css: {'text-align': 'right', 'color':'#777'}} ], }); \ No newline at end of file diff --git a/public/js/all-app.js b/public/js/all-app.js index 384f8f9d5e..4176fb542b 100644 --- a/public/js/all-app.js +++ b/public/js/all-app.js @@ -968,13 +968,13 @@ wn.views.DocListView=wn.ui.Listing.extend({init:function(doctype){this.doctype=d
    \ ');this.appframe=new wn.ui.AppFrame(this.$page.find('.appframe-area'));wn.views.breadcrumbs($('').appendTo(this.appframe.$titlebar),locals.DocType[this.doctype].module,this.doctype);},setup:function(){var me=this;me.can_delete=wn.model.can_delete(me.doctype);me.meta=locals.DocType[me.doctype];me.$page.find('.wnlist-area').empty(),me.setup_docstatus_filter();me.setup_listview();me.init_list();me.init_stats();me.make_report_button();me.add_delete_option();},make_report_button:function(){var me=this;if(wn.boot.profile.can_get_report.indexOf(this.doctype)!=-1){this.appframe.add_button('Build Report',function(){wn.set_route('Report2',me.doctype);},'icon-th')}},setup_docstatus_filter:function(){var me=this;this.can_submit=$.map(locals.DocPerm,function(d){if(d.parent==me.meta.name&&d.submit)return 1 else return null;}).length;if(this.can_submit){this.$page.find('.show-docstatus').removeClass('hide');this.$page.find('.show-docstatus input').click(function(){me.run();})}},setup_listview:function(){if(this.meta.__listjs){eval(this.meta.__listjs);this.listview=new wn.doclistviews[this.doctype](this);}else{this.listview=new wn.views.ListView(this);} -this.listview.parent=this;this.wrapper=this.$page.find('.wnlist-area');this.page_length=20;this.allow_delete=true;},init_list:function(auto_run){this.make({method:'webnotes.widgets.doclistview.get',get_args:this.get_args,parent:this.wrapper,start:0,page_length:this.page_length,show_filters:true,show_grid:true,new_doctype:this.doctype,allow_delete:this.allow_delete,no_result_message:this.make_no_result(),columns:this.listview.fields});if((auto_run!==false)&&(auto_run!==0))this.run();},make_no_result:function(){return repl('

    No %(doctype_label)s found

    \ +this.listview.parent=this;this.wrapper=this.$page.find('.wnlist-area');this.page_length=20;this.allow_delete=true;},init_list:function(auto_run){var me=this;this.make({method:'webnotes.widgets.doclistview.get',get_args:this.get_args,parent:this.wrapper,start:0,page_length:this.page_length,show_filters:true,show_grid:true,new_doctype:this.doctype,allow_delete:this.allow_delete,no_result_message:this.make_no_result(),columns:this.listview.fields});$(this.wrapper).find('button[list_view_doc="'+me.doctype+'"]').click(function(){me.make_new_doc(me.doctype);});if((auto_run!==false)&&(auto_run!==0))this.run();},make_no_result:function(){var no_result_message=repl('
    \ +

    No %(doctype_label)s found

    \ %(description)s\
    \ -

    \ -

    ',{doctype_label:get_doctype_label(this.doctype),doctype:this.doctype,description:wn.markdown(locals.DocType[this.doctype].description||'')});},render_row:function(row,data){data.doctype=this.doctype;this.listview.render(row,data,this);},get_query_fields:function(){return this.listview.fields;},get_args:function(){return{doctype:this.doctype,fields:this.get_query_fields(),filters:this.filter_list.get_filters(),docstatus:this.can_submit?$.map(this.$page.find('.show-docstatus :checked'),function(inp){return $(inp).attr('data-docstatus')}):[],order_by:this.listview.order_by||undefined,}},add_delete_option:function(){var me=this;if(this.can_delete){this.add_button('Delete',function(){me.delete_items();},'icon-remove')}},delete_items:function(){var me=this;var dl=$.map(me.$page.find('.list-delete:checked'),function(e){return $(e).data('name');});if(!dl.length) +

    \ +

    ',{doctype_label:get_doctype_label(this.doctype),doctype:this.doctype,description:wn.markdown(locals.DocType[this.doctype].description||''),});return no_result_message;},render_row:function(row,data){data.doctype=this.doctype;this.listview.render(row,data,this);},get_query_fields:function(){return this.listview.fields;},get_args:function(){return{doctype:this.doctype,fields:this.get_query_fields(),filters:this.filter_list.get_filters(),docstatus:this.can_submit?$.map(this.$page.find('.show-docstatus :checked'),function(inp){return $(inp).attr('data-docstatus')}):[],order_by:this.listview.order_by||undefined,}},add_delete_option:function(){var me=this;if(this.can_delete){this.add_button('Delete',function(){me.delete_items();},'icon-remove')}},delete_items:function(){var me=this;var dl=$.map(me.$page.find('.list-delete:checked'),function(e){return $(e).data('name');});if(!dl.length) return;if(!confirm('This is PERMANENT action and you cannot undo. Continue?')){return;} me.set_working(true);wn.call({method:'webnotes.widgets.doclistview.delete_items',args:{items:dl,doctype:me.doctype},callback:function(){me.set_working(false);me.refresh();}})},init_stats:function(){var me=this wn.call({method:'webnotes.widgets.doclistview.get_stats',args:{stats:me.listview.stats,doctype:me.doctype},callback:function(r){$.each(me.listview.stats,function(i,v){me.render_stat(v,r.message[v]);});if(me.listview.stats.length){$('').click(function(){me.reload_stats();}).appendTo($('
    ').appendTo(me.$page.find('.layout-side-section')))}}});},render_stat:function(field,stat){var me=this;if(!stat||!stat.length){if(field=='_user_tags'){this.$page.find('.layout-side-section').append('

    Tags

    \ @@ -1015,11 +1015,10 @@ $(parent).append(repl(''+data[opts.content]+'',data));} else if(opts.template){$(parent).append(repl(opts.template,data));} -else if(data[opts.content]){$(parent).append(' '+data[opts.content]);}},render:function(row,data){var me=this;this.prepare_data(data);rowhtml='';$.each(this.columns,function(i,v){rowhtml+=repl('',v);});var tr=$(row).html(''+rowhtml+'
    ').find('tr').get(0);$.each(this.columns,function(i,v){me.render_column(data,tr.cells[i],v);});},prepare_data:function(data){data.fullname=wn.user_info(data.owner).fullname;data.avatar=wn.user_info(data.owner).image;data.when=dateutil.str_to_user(data.modified).split(' ')[0];var diff=dateutil.get_diff(dateutil.get_today(),data.modified.split(' ')[0]);if(diff==0){data.when=dateutil.comment_when(data.modified);} +else if(data[opts.content]){$(parent).append(' '+data[opts.content]);}},render:function(row,data){var me=this;this.prepare_data(data);rowhtml='';$.each(this.columns,function(i,v){rowhtml+=repl('',v);});var tr=$(row).html(''+rowhtml+'
    ').find('tr').get(0);$.each(this.columns,function(i,v){me.render_column(data,tr.cells[i],v);});},prepare_data:function(data){data.fullname=wn.user_info(data.owner).fullname;data.avatar=wn.user_info(data.owner).image;this.prepare_when(data,data.modified);if(data.docstatus==0||data.docstatus==null){data.docstatus_icon='icon-pencil';data.docstatus_title='Editable';}else if(data.docstatus==1){data.docstatus_icon='icon-lock';data.docstatus_title='Submitted';}else if(data.docstatus==2){data.docstatus_icon='icon-remove';data.docstatus_title='Cancelled';} +for(key in data){if(data[key]==null){data[key]='';}}},prepare_when:function(data,date_str){if(!date_str)date_str=data.modified;data.when=dateutil.str_to_user(date_str).split(' ')[0];var diff=dateutil.get_diff(dateutil.get_today(),date_str.split(' ')[0]);if(diff==0){data.when=dateutil.comment_when(date_str);} if(diff==1){data.when='Yesterday'} -if(diff==2){data.when='2 days ago'} -if(data.docstatus==0||data.docstatus==null){data.docstatus_icon='icon-pencil';data.docstatus_title='Editable';}else if(data.docstatus==1){data.docstatus_icon='icon-lock';data.docstatus_title='Submitted';}else if(data.docstatus==2){data.docstatus_icon='icon-remove';data.docstatus_title='Cancelled';} -for(key in data){if(data[key]==null){data[key]='';}}},add_user_tags:function(parent,data){var me=this;if(data._user_tags){if($(parent).html().length>0){$(parent).append('
    ');} +if(diff==2){data.when='2 days ago'}},add_user_tags:function(parent,data){var me=this;if(data._user_tags){if($(parent).html().length>0){$(parent).append('
    ');} $.each(data._user_tags.split(','),function(i,t){if(t){$('' +strip(t)+'').click(function(){me.doclistview.set_filter('_user_tags',$(this).text())}).appendTo(parent);}});}},show_hide_check_column:function(){if(!this.doclistview.can_delete){this.columns=$.map(this.columns,function(v,i){if(v.content!='check')return v});}}});wn.provide('wn.views.RecordListView');wn.views.RecordListView=wn.views.DocListView.extend({init:function(doctype,wrapper,ListView){this.doctype=doctype;this.wrapper=wrapper;this.listview=new ListView(this);this.listview.parent=this;this.setup();},setup:function(){var me=this;me.page_length=10;$(me.wrapper).empty();me.init_list();},get_args:function(){var args=this._super();$.each((this.default_filters||[]),function(i,f){args.filters.push(f);});args.docstatus=args.docstatus.concat((this.default_docstatus||[]));return args;},}); /* @@ -1033,7 +1032,7 @@ wn.container.change_to('Form - '+dt);wn.views.formview[dt].frm.refresh(dn);});}) * lib/js/wn/views/reportview.js */ wn.views.reportview={show:function(dt,rep_name){wn.require('js/report-legacy.js');dt=get_label_doctype(dt);if(!_r.rb_con){_r.rb_con=new _r.ReportContainer();} -_r.rb_con.set_dt(dt,function(rb){if(rep_name){var t=rb.current_loaded;var route_changed=(rb.current_route!=wn.get_route_str()) +_r.rb_con.set_dt(dt,function(rb){if(rep_name){var route_changed=(rb.current_route!=wn.get_route_str()) rb.load_criteria(rep_name);if(rb.dt&&route_changed){rb.dt.run();}} if(!rb.forbidden){wn.container.change_to('Report Builder');}});}} wn.views.reportview2={show:function(dt){var page_name=wn.get_route_str();if(wn.pages[page_name]){wn.container.change_to(wn.pages[page_name]);}else{var route=wn.get_route();if(route[1]){new wn.views.ReportViewPage(route[1],route[2]);}else{wn.set_route('404');}}}} From fef4a71177b748603614b4bb5cedc86a36c9556f Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Thu, 28 Jun 2012 13:05:39 +0530 Subject: [PATCH 06/13] minor fix in communication list view --- erpnext/support/doctype/communication/listview.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/erpnext/support/doctype/communication/listview.js b/erpnext/support/doctype/communication/listview.js index 04346f90de..c00681be9e 100644 --- a/erpnext/support/doctype/communication/listview.js +++ b/erpnext/support/doctype/communication/listview.js @@ -16,8 +16,10 @@ wn.doclistviews['Communication'] = wn.views.ListView.extend({ this.prepare_when(data, data.creation); // escape double quote - data.content = cstr(data.subject).replace(/"/gi, '\"') - + " | " + cstr(data.content).replace(/"/gi, '\"'); + data.content = cstr(data.subject) + + " | " + cstr(data.content); + data.content = data.content.replace(/"/gi, '\"') + .replace(//gi, '>'); if(data.content && data.content.length > 50) { data.content = '' + From 36f5e257ed770b41eb9adfa4e033e99761829dcc Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Thu, 28 Jun 2012 13:08:43 +0530 Subject: [PATCH 07/13] minor fix in support ticket list view --- erpnext/support/doctype/support_ticket/listview.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/erpnext/support/doctype/support_ticket/listview.js b/erpnext/support/doctype/support_ticket/listview.js index eb0ba72551..3bbb197df7 100644 --- a/erpnext/support/doctype/support_ticket/listview.js +++ b/erpnext/support/doctype/support_ticket/listview.js @@ -34,9 +34,12 @@ wn.doclistviews['Support Ticket'] = wn.views.ListView.extend({ }); // escape double quotes - data.description = cstr(data.subject).replace(/"/gi, '\"') - + " | " + cstr(data.description).replace(/"/gi, '\"'); - + data.description = cstr(data.subject) + + " | " + cstr(data.description); + + data.description = data.description.replace(/"/gi, '\"') + .replace(//gi, '>'); + // description if(data.description && data.description.length > 50) { data.description = '' + data.description.substr(0,50) + '...'; From 1f69f92d2f871b81e02fe74e2129041947e4c935 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Fri, 29 Jun 2012 13:25:08 +0530 Subject: [PATCH 08/13] supplier part number in purchase order --- .../purchase_common/purchase_common.py | 10 ++++++++- .../purchase_order_item.txt | 21 +++++++++++++++---- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/erpnext/buying/doctype/purchase_common/purchase_common.py b/erpnext/buying/doctype/purchase_common/purchase_common.py index fd02b02128..7240a2d229 100644 --- a/erpnext/buying/doctype/purchase_common/purchase_common.py +++ b/erpnext/buying/doctype/purchase_common/purchase_common.py @@ -131,7 +131,7 @@ class DocType(TransactionBase): 'warehouse': wh, 'item_tax_rate': json.dumps(t), 'batch_no': '', - 'discount_rate': 0 + 'discount_rate': 0 } # get min_order_qty from item @@ -170,6 +170,14 @@ class DocType(TransactionBase): 'import_rate': 0, }) + if obj.doc.doctype == 'Purchase Order': + supplier_part_no = webnotes.conn.sql("""\ + select supplier_part_no from `tabItem Supplier` + where parent = %s and parenttype = 'Item' and + supplier = %s""", (arg['item_code'], obj.doc.supplier)) + if supplier_part_no and supplier_part_no[0][0]: + ret['supplier_part_no'] = supplier_part_no[0][0] + return ret # Get Available Qty at Warehouse 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 499cdefc11..73a6f0165f 100755 --- a/erpnext/buying/doctype/purchase_order_item/purchase_order_item.txt +++ b/erpnext/buying/doctype/purchase_order_item/purchase_order_item.txt @@ -3,9 +3,9 @@ # These values are common in all dictionaries { - 'creation': '2012-03-27 14:35:50', + 'creation': '2012-05-15 12:14:38', 'docstatus': 0, - 'modified': '2012-03-27 14:35:50', + 'modified': '2012-06-29 13:05:33', 'modified_by': u'Administrator', 'owner': u'Administrator' }, @@ -22,7 +22,7 @@ 'section_style': u'Tray', 'server_code_error': u' ', 'show_in_menu': 0, - 'version': 65 + 'version': 1 }, # These values are common for all DocField @@ -74,6 +74,19 @@ 'trigger': u'Client' }, + # DocField + { + 'colour': u'White:FFF', + 'description': u'If Supplier Part Number exists for given Item, it gets stored here', + 'doctype': u'DocField', + 'fieldname': u'supplier_part_no', + 'fieldtype': u'Data', + 'hidden': 1, + 'label': u'Supplier Part Number', + 'permlevel': 1, + 'print_hide': 1 + }, + # DocField { 'doctype': u'DocField', @@ -453,4 +466,4 @@ 'permlevel': 0, 'print_hide': 1 } -] +] \ No newline at end of file From ebe23b0f89339ab33be65fc40e0c187e83b2dc08 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Fri, 29 Jun 2012 16:38:07 +0530 Subject: [PATCH 09/13] allow deletion of communication --- erpnext/support/doctype/communication/listview.js | 2 +- public/js/all-app.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/erpnext/support/doctype/communication/listview.js b/erpnext/support/doctype/communication/listview.js index c00681be9e..ec87692b5f 100644 --- a/erpnext/support/doctype/communication/listview.js +++ b/erpnext/support/doctype/communication/listview.js @@ -28,8 +28,8 @@ wn.doclistviews['Communication'] = wn.views.ListView.extend({ }, columns: [ + {width: '3%', content: 'check'}, {width: '5%', content: 'avatar'}, - {width: '3%', content: 'docstatus'}, {width: '15%', content: 'name'}, {width: '15%', content: 'category'}, {width: '55%', content: 'content+tags'}, diff --git a/public/js/all-app.js b/public/js/all-app.js index 4176fb542b..791c0a3f44 100644 --- a/public/js/all-app.js +++ b/public/js/all-app.js @@ -1835,7 +1835,7 @@ _f.Frm.prototype.savedoc=function(save_action,onsave,onerr){this.error_in_sectio _f.Frm.prototype.saveupdate=function(){this.save('Update');} _f.Frm.prototype.savesubmit=function(){var answer=confirm("Permanently Submit "+this.docname+"?");var me=this;if(answer){this.save('Submit',function(r){if(!r.exc&&me.cscript.on_submit){me.runclientscript('on_submit',me.doctype,me.docname);}});}} _f.Frm.prototype.savecancel=function(){var answer=confirm("Permanently Cancel "+this.docname+"?");if(answer)this.save('Cancel');} -_f.Frm.prototype.savetrash=function(){var me=this;var answer=confirm("Permanently Delete "+this.docname+"? This action cannot be reversed");if(answer){$c('webnotes.model.delete_doc',{dt:this.doctype,dn:this.docname},function(r,rt){if(r.message=='okay'){LocalDB.delete_doc(me.doctype,me.docname);if(wn.ui.toolbar.recent)wn.ui.toolbar.recent.remove(me.doctype,me.docname);window.back();}})}} +_f.Frm.prototype.savetrash=function(){var me=this;var answer=confirm("Permanently Delete "+this.docname+"? This action cannot be reversed");if(answer){$c('webnotes.model.delete_doc',{dt:this.doctype,dn:this.docname},function(r,rt){if(r.message=='okay'){LocalDB.delete_doc(me.doctype,me.docname);if(wn.ui.toolbar.recent)wn.ui.toolbar.recent.remove(me.doctype,me.docname);window.history.back();}})}} _f.Frm.prototype.amend_doc=function(){if(!this.fields_dict['amended_from']){alert('"amended_from" field must be present to do an amendment.');return;} var me=this;var fn=function(newdoc){newdoc.amended_from=me.docname;if(me.fields_dict&&me.fields_dict['amendment_date']) newdoc.amendment_date=dateutil.obj_to_str(new Date());} @@ -2169,7 +2169,7 @@ CommentItem.prototype.cmt_delete=function(cell,ri,ci,d){var me=this;if(d[ri][2]= /* * lib/js/legacy/wn/widgets/form/sidebar.js */ -wn.widgets.form.sidebar={Sidebar:function(form){var me=this;this.form=form;this.opts={sections:[{title:'Actions',items:[{type:'link',label:'New',icon:'icon-plus',display:function(){return in_list(profile.can_create,form.doctype)},onclick:function(){new_doc(me.form.doctype)}},{type:'link',label:'List',icon:'icon-list',display:function(){return!me.form.meta.issingle;},onclick:function(){window.location.href="#!List/"+me.form.doctype}},{type:'link',label:'Refresh',icon:'icon-refresh',onclick:function(){me.form.reload_doc()}},{type:'link',label:'Print',display:function(){return!(me.form.doc.__islocal||me.form.meta.allow_print);},icon:'icon-print',onclick:function(){me.form.print_doc()}},{type:'link',label:'Email',display:function(){return!(me.form.doc.__islocal||me.form.meta.allow_email);},icon:'icon-envelope',onclick:function(){me.form.email_doc()}},{type:'link',label:'Copy',display:function(){return in_list(profile.can_create,me.form.doctype)&&!me.form.meta.allow_copy},icon:'icon-file',onclick:function(){me.form.copy_doc()}},{type:'link',label:'Delete',display:function(){return me.form.meta.allow_trash&&cint(me.form.doc.docstatus)!=2&&(!me.form.doc.__islocal)&&me.form.perm[0][CANCEL]},icon:'icon-remove-sign',onclick:function(){me.form.savetrash()}}]},{title:'Assign To',render:function(wrapper){me.form.assign_to=new wn.widgets.form.sidebar.AssignTo(wrapper,me,me.form.doctype,me.form.docname);},display:function(){if(me.form.doc.__local)return false;else return true;}},{title:'Attachments',render:function(wrapper){me.form.attachments=new wn.widgets.form.sidebar.Attachments(wrapper,me,me.form.doctype,me.form.docname);},display:function(){return me.form.meta.allow_attach}},{title:'Comments',render:function(wrapper){new wn.widgets.form.sidebar.Comments(wrapper,me,me.form.doctype,me.form.docname);},display:function(){return!me.form.doc.__islocal}},{title:'Tags',render:function(wrapper){me.form.taglist=new TagList(wrapper,me.form.doc._user_tags?me.form.doc._user_tags.split(','):[],me.form.doctype,me.form.docname,0,function(){});},display:function(){return!me.form.doc.__islocal}},{title:'Users',render:function(wrapper){var doc=cur_frm.doc;var scrub_date=function(d){if(d)t=d.split(' ');else return'';return dateutil.str_to_user(t[0])+' '+t[1];} +wn.widgets.form.sidebar={Sidebar:function(form){var me=this;this.form=form;this.opts={sections:[{title:'Actions',items:[{type:'link',label:'New',icon:'icon-plus',display:function(){return in_list(profile.can_create,form.doctype)},onclick:function(){new_doc(me.form.doctype)}},{type:'link',label:'List',icon:'icon-list',display:function(){return!me.form.meta.issingle;},onclick:function(){window.location.href="#!List/"+me.form.doctype}},{type:'link',label:'Refresh',icon:'icon-refresh',onclick:function(){me.form.reload_doc()}},{type:'link',label:'Print',display:function(){return!(me.form.doc.__islocal||me.form.meta.allow_print);},icon:'icon-print',onclick:function(){me.form.print_doc()}},{type:'link',label:'Email',display:function(){return!(me.form.doc.__islocal||me.form.meta.allow_email);},icon:'icon-envelope',onclick:function(){me.form.email_doc()}},{type:'link',label:'Copy',display:function(){return in_list(profile.can_create,me.form.doctype)&&!me.form.meta.allow_copy},icon:'icon-file',onclick:function(){me.form.copy_doc()}},{type:'link',label:'Delete',display:function(){return(cint(me.form.doc.docstatus)!=1)&&!me.form.doc.__islocal&&wn.model.can_delete(me.form.doctype);},icon:'icon-remove-sign',onclick:function(){me.form.savetrash()}}]},{title:'Assign To',render:function(wrapper){me.form.assign_to=new wn.widgets.form.sidebar.AssignTo(wrapper,me,me.form.doctype,me.form.docname);},display:function(){if(me.form.doc.__local)return false;else return true;}},{title:'Attachments',render:function(wrapper){me.form.attachments=new wn.widgets.form.sidebar.Attachments(wrapper,me,me.form.doctype,me.form.docname);},display:function(){return me.form.meta.allow_attach}},{title:'Comments',render:function(wrapper){new wn.widgets.form.sidebar.Comments(wrapper,me,me.form.doctype,me.form.docname);},display:function(){return!me.form.doc.__islocal}},{title:'Tags',render:function(wrapper){me.form.taglist=new TagList(wrapper,me.form.doc._user_tags?me.form.doc._user_tags.split(','):[],me.form.doctype,me.form.docname,0,function(){});},display:function(){return!me.form.doc.__islocal}},{title:'Users',render:function(wrapper){var doc=cur_frm.doc;var scrub_date=function(d){if(d)t=d.split(' ');else return'';return dateutil.str_to_user(t[0])+' '+t[1];} $(wrapper).html(repl('

    Created:
    \ \ %(creation)s

    \ From e9a21cbb85f452b46d86ec13ace7ffff274eab76 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Fri, 29 Jun 2012 18:09:04 +0530 Subject: [PATCH 10/13] show child table values in doclistview --- .../stock/doctype/purchase_receipt/listview.js | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/erpnext/stock/doctype/purchase_receipt/listview.js b/erpnext/stock/doctype/purchase_receipt/listview.js index c1b8b42f75..915565723b 100644 --- a/erpnext/stock/doctype/purchase_receipt/listview.js +++ b/erpnext/stock/doctype/purchase_receipt/listview.js @@ -4,16 +4,27 @@ wn.doclistviews['Purchase Receipt'] = wn.views.ListView.extend({ this._super(d); this.fields = this.fields.concat([ "`tabPurchase Receipt`.supplier_name", - "`tabPurchase Receipt`.purchase_order_no" + "group_concat(`tabPurchase Receipt Item`.prevdoc_docname) as purchase_order_no", ]); }, + prepare_data: function(data) { + this._super(data); + if(data.purchase_order_no) { + data.purchase_order_no = data.purchase_order_no.split(","); + var po_list = []; + $.each(data.purchase_order_no, function(i, v){ + if(po_list.indexOf(v)==-1) po_list.push(v); + }); + data.purchase_order_no = po_list.join(", "); + } + }, columns: [ {width: '3%', content: 'check'}, {width: '5%', content:'avatar'}, {width: '3%', content:'docstatus'}, {width: '15%', content:'name'}, - {width: '47%', content:'supplier_name+tags', css: {color:'#222'}}, - {width: '15%', content:'purchase_order_no', type:'link', doctype:'Purchase Order'}, + {width: '32%', content:'supplier_name+tags', css: {color:'#222'}}, + {width: '30%', content:'purchase_order_no'}, {width: '12%', content:'modified', css: {'text-align': 'right', 'color':'#777'}} ] }); From cec84e1ec76579f84c2703132a1d81c897cd31aa Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Mon, 2 Jul 2012 11:55:29 +0530 Subject: [PATCH 11/13] logout a disabled user --- erpnext/utilities/page/users/users.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/erpnext/utilities/page/users/users.py b/erpnext/utilities/page/users/users.py index 5b76a2a4c7..347c9b2f26 100644 --- a/erpnext/utilities/page/users/users.py +++ b/erpnext/utilities/page/users/users.py @@ -81,6 +81,10 @@ def update_security(args=''): webnotes.conn.set_value('Profile', args['user'], 'login_after', args.get('login_after') or None) webnotes.conn.set_value('Profile', args['user'], 'login_before', args.get('login_before') or None) webnotes.conn.set_value('Profile', args['user'], 'enabled', int(args.get('enabled',0)) or 0) + + # logout a disabled user + if not int(args.get('enabled',0) or 0): + webnotes.login_manager.logout(user=args['user']) if args.get('new_password') and args.get('sys_admin_pwd'): from webnotes.utils import cint From d383e573fc36da60a2e68a48b421b3490b5b25dc Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Mon, 2 Jul 2012 19:45:35 +0530 Subject: [PATCH 12/13] contact, address list views and allow their deletion from customer / supplier form --- erpnext/buying/doctype/supplier/supplier.js | 29 +--- .../buying/page/buying_home/buying_home.html | 6 + erpnext/selling/doctype/customer/customer.js | 29 +--- .../page/selling_home/selling_home.html | 6 + .../contact_control/contact_control.js | 137 ++++++++++++++++++ .../permission_control/permission_control.py | 5 +- erpnext/utilities/doctype/address/address.py | 1 - erpnext/utilities/doctype/address/listview.js | 55 +++++++ erpnext/utilities/doctype/contact/contact.py | 1 - erpnext/utilities/doctype/contact/listview.js | 50 +++++++ 10 files changed, 265 insertions(+), 54 deletions(-) create mode 100644 erpnext/utilities/doctype/address/listview.js create mode 100644 erpnext/utilities/doctype/contact/listview.js diff --git a/erpnext/buying/doctype/supplier/supplier.js b/erpnext/buying/doctype/supplier/supplier.js index 2334cdd7ed..a5b928fe23 100644 --- a/erpnext/buying/doctype/supplier/supplier.js +++ b/erpnext/buying/doctype/supplier/supplier.js @@ -62,24 +62,9 @@ cur_frm.cscript.make_address = function() { }, as_dict: 1, no_results_message: 'No addresses created', - render_row: function(wrapper, data) { - $(wrapper).css('padding','5px 0px'); - var link = $ln(wrapper,cstr(data.name), function() { loaddoc("Address", this.dn); }, {fontWeight:'bold'}); - link.dn = data.name - - $a(wrapper,'span','',{marginLeft:'5px', color: '#666'},(data.is_primary_address ? '[Primary]' : '') + (data.is_shipping_address ? '[Shipping]' : '')); - $a(wrapper,'div','',{marginTop:'5px', color:'#555'}, - (data.address_line1 ? data.address_line1 + '
    ' : '') + - (data.address_line2 ? data.address_line2 + '
    ' : '') + - (data.city ? data.city + '
    ' : '') + - (data.state ? data.state + ', ' : '') + - (data.country ? data.country + '
    ' : '') + - (data.pincode ? 'Pincode: ' + data.pincode + '
    ' : '') + - (data.phone ? 'Phone: ' + data.phone + '
    ' : '') + - (data.fax ? 'Fax: ' + data.fax + '
    ' : '') + - (data.email_id ? 'Email: ' + data.email_id + '
    ' : '')); - } + render_row: cur_frm.cscript.render_address_row, }); + // note: render_address_row is defined in contact_control.js } cur_frm.address_list.run(); } @@ -95,15 +80,9 @@ cur_frm.cscript.make_contact = function() { }, as_dict: 1, no_results_message: 'No contacts created', - render_row: function(wrapper, data) { - $(wrapper).css('padding', '5px 0px'); - var link = $ln(wrapper, cstr(data.name), function() { loaddoc("Contact", this.dn); }, {fontWeight:'bold'}); - link.dn = data.name - - $a(wrapper,'span','',{marginLeft:'5px', color: '#666'},(data.is_primary_contact ? '[Primary]' : '')); - $a(wrapper,'div', '',{marginTop:'5px', color:'#555'}, data.first_name + (data.last_name ? ' ' + data.last_name + '
    ' : '
    ') + (data.phone ? 'Tel: ' + data.phone + '
    ' : '') + (data.mobile_no ? 'Mobile: ' + data.mobile_no + '
    ' : '') + (data.email_id ? 'Email: ' + data.email_id + '
    ' : '') + (data.department ? 'Department: ' + data.department + '
    ' : '') + (data.designation ? 'Designation: ' + data.designation + '
    ' : '')); - } + render_row: cur_frm.cscript.render_contact_row, }); + // note: render_contact_row is defined in contact_control.js } cur_frm.contact_list.run(); } diff --git a/erpnext/buying/page/buying_home/buying_home.html b/erpnext/buying/page/buying_home/buying_home.html index ff8b0ab610..8e28e1b1e1 100644 --- a/erpnext/buying/page/buying_home/buying_home.html +++ b/erpnext/buying/page/buying_home/buying_home.html @@ -14,6 +14,12 @@

    Item

    Item Master

    +
    +

    Contact

    +

    Contact Master

    +
    +

    Address

    +

    Address Master


    diff --git a/erpnext/selling/doctype/customer/customer.js b/erpnext/selling/doctype/customer/customer.js index f49a1abca7..708573d836 100644 --- a/erpnext/selling/doctype/customer/customer.js +++ b/erpnext/selling/doctype/customer/customer.js @@ -81,24 +81,9 @@ cur_frm.cscript.make_address = function() { }, as_dict: 1, no_results_message: 'No addresses created', - render_row: function(wrapper, data) { - $(wrapper).css('padding','5px 0px'); - var link = $ln(wrapper,cstr(data.name), function() { loaddoc("Address", this.dn); }, {fontWeight:'bold'}); - link.dn = data.name - - $a(wrapper,'span','',{marginLeft:'5px', color: '#666'},(data.is_primary_address ? '[Primary]' : '') + (data.is_shipping_address ? '[Shipping]' : '')); - $a(wrapper,'div','',{marginTop:'5px', color:'#555'}, - (data.address_line1 ? data.address_line1 + '
    ' : '') + - (data.address_line2 ? data.address_line2 + '
    ' : '') + - (data.city ? data.city + '
    ' : '') + - (data.state ? data.state + ', ' : '') + - (data.country ? data.country + '
    ' : '') + - (data.pincode ? 'Pincode: ' + data.pincode + '
    ' : '') + - (data.phone ? 'Phone: ' + data.phone + '
    ' : '') + - (data.fax ? 'Fax: ' + data.fax + '
    ' : '') + - (data.email_id ? 'Email: ' + data.email_id + '
    ' : '')); - } + render_row: cur_frm.cscript.render_address_row, }); + // note: render_address_row is defined in contact_control.js } cur_frm.address_list.run(); } @@ -114,15 +99,9 @@ cur_frm.cscript.make_contact = function() { }, as_dict: 1, no_results_message: 'No contacts created', - render_row: function(wrapper, data) { - $(wrapper).css('padding', '5px 0px'); - var link = $ln(wrapper, cstr(data.name), function() { loaddoc("Contact", this.dn); }, {fontWeight:'bold'}); - link.dn = data.name - - $a(wrapper,'span','',{marginLeft:'5px', color: '#666'},(data.is_primary_contact ? '[Primary]' : '')); - $a(wrapper,'div', '',{marginTop:'5px', color:'#555'}, data.first_name + (data.last_name ? ' ' + data.last_name + '
    ' : '
    ') + (data.phone ? 'Tel: ' + data.phone + '
    ' : '') + (data.mobile_no ? 'Mobile: ' + data.mobile_no + '
    ' : '') + (data.email_id ? 'Email: ' + data.email_id + '
    ' : '') + (data.department ? 'Department: ' + data.department + '
    ' : '') + (data.designation ? 'Designation: ' + data.designation + '
    ' : '')); - } + render_row: cur_frm.cscript.render_contact_row, }); + // note: render_contact_row is defined in contact_control.js } cur_frm.contact_list.run(); diff --git a/erpnext/selling/page/selling_home/selling_home.html b/erpnext/selling/page/selling_home/selling_home.html index acadfd63ff..4857def11b 100644 --- a/erpnext/selling/page/selling_home/selling_home.html +++ b/erpnext/selling/page/selling_home/selling_home.html @@ -20,6 +20,12 @@

    Item

    Item Master

    +
    +

    Contact

    +

    Contact Master

    +
    +

    Address

    +

    Address Master


    diff --git a/erpnext/setup/doctype/contact_control/contact_control.js b/erpnext/setup/doctype/contact_control/contact_control.js index a07fd832be..b64b589155 100755 --- a/erpnext/setup/doctype/contact_control/contact_control.js +++ b/erpnext/setup/doctype/contact_control/contact_control.js @@ -77,3 +77,140 @@ if(cur_frm.fields_dict['territory']){ return 'SELECT `tabTerritory`.`name`,`tabTerritory`.`parent_territory` FROM `tabTerritory` WHERE `tabTerritory`.`is_group` = "No" AND `tabTerritory`.`docstatus`!= 2 AND `tabTerritory`.%(key)s LIKE "%s" ORDER BY `tabTerritory`.`name` ASC LIMIT 50'; } } + +cur_frm.cscript.render_contact_row = function(wrapper, data) { + // prepare data + data.fullname = (data.first_name || '') + + (data.last_name ? ' ' + data.last_name : ''); + data.primary = data.is_primary_contact ? ' [Primary]' : ''; + + // prepare description + var description = []; + $.each([ + ['phone', 'Tel'], + ['mobile_no', 'Mobile'], + ['email_id', 'Email'], + ['department', 'Department'], + ['designation', 'Designation']], + function(i, v) { + if(v[0] && data[v[0]]) { + description.push(repl('
    %(label)s:
    %(value)s', { + label: v[1], + value: data[v[0]], + })); + } + }); + data.description = description.join('
    '); + + cur_frm.cscript.render_row_in_wrapper(wrapper, data, 'Contact'); +} + +cur_frm.cscript.render_address_row = function(wrapper, data) { + // prepare data + data.fullname = data.address_type; + data.primary = ''; + if (data.is_primary_address) data.primary += ' [Primary]'; + if (data.is_shipping_address) data.primary += ' [Shipping]'; + + // prepare address + var address = []; + $.each(['address_line1', 'address_line2', 'city', 'state', 'country', 'pincode'], + function(i, v) { + if(data[v]) address.push(data[v]); + }); + + data.address = address.join('
    '); + data.address = "

    " + data.address + "

    "; + + // prepare description + var description = []; + $.each([ + ['address', 'Address'], + ['phone', 'Tel'], + ['fax', 'Fax'], + ['email_id', 'Email']], + function(i, v) { + if(data[v[0]]) { + description.push(repl('
    %(label)s:
    %(value)s', { + label: v[1], + value: data[v[0]], + })); + } + }); + data.description = description.join('
    '); + + cur_frm.cscript.render_row_in_wrapper(wrapper, data, 'Address'); + + $(wrapper).find('p.address-list').css({ + 'padding-left': '10px', + 'margin-bottom': '-10px' + }); +} + +cur_frm.cscript.render_row_in_wrapper = function(wrapper, data, doctype) { + // render + var $wrapper = $(wrapper); + + data.doctype = doctype.toLowerCase(); + + $wrapper.append(repl("\ +

    %(fullname)s%(primary)s

    \ +
    \ + %(description)s\ +

    delete this %(doctype)s

    \ +
    ", data)); + + // make link + $wrapper.find('h4 a.link_type').click(function() { + loaddoc(doctype, data.name); + }); + + // css + $wrapper.css({ 'padding': '5px 0px' }); + $wrapper.find('div.description').css({ + 'padding': '5px 2px', + 'line-height': '150%', + }); + $wrapper.find('h6').css({ 'display': 'inline-block' }); + + // show delete + var $delete_doc = $wrapper.find('a.delete'); + if (wn.model.can_delete(doctype)) { + $delete_doc.toggle(true); + } else { + $delete_doc.toggle(false); + } + $delete_doc.css({ + 'padding-left': '0px' + }); + + $delete_doc.click(function() { + cur_frm.cscript.delete_doc(doctype, data.name); + return false; + }); +} + +cur_frm.cscript.delete_doc = function(doctype, name) { + // confirm deletion + var go_ahead = confirm(repl('Delete %(doctype)s "%(name)s"', { + doctype: doctype, + name: name + })); + if (!go_ahead) return; + + wn.call({ + method: 'webnotes.model.delete_doc', + args: { + dt: doctype, + dn: name + }, + callback: function(r) { + //console.log(r); + if (!r.exc) { + // run the correct list + var list_name = doctype.toLowerCase() + '_list'; + cur_frm[list_name].run(); + } + } + }); +} diff --git a/erpnext/setup/doctype/permission_control/permission_control.py b/erpnext/setup/doctype/permission_control/permission_control.py index 42f0c97333..9d6f428a14 100644 --- a/erpnext/setup/doctype/permission_control/permission_control.py +++ b/erpnext/setup/doctype/permission_control/permission_control.py @@ -43,10 +43,11 @@ class DocType: # ----------------------------------------------------- def get_doctype_list(self): ret = sql("""SELECT `name` FROM tabDocType - WHERE ifnull(docstatus,0)=0 + WHERE ifnull(docstatus,0)=0 AND ifnull(istable,0)=0 AND ifnull(issingle,0)=0 - AND `module` NOT IN ('System','Utilities','Setup Masters','Roles','Recycle Bin','Mapper','Application Internal','Development', 'Core') + AND (`module` NOT IN ('System','Utilities','Setup Masters','Roles','Recycle Bin','Mapper','Application Internal','Development', 'Core') + OR name IN ('Contact', 'Address')) ORDER BY `name` ASC""") rl = [''] + [a[0] for a in sql("select name from tabRole where ifnull(docstatus,0)=0")] diff --git a/erpnext/utilities/doctype/address/address.py b/erpnext/utilities/doctype/address/address.py index f4a72fdb2c..cd6a188ca9 100644 --- a/erpnext/utilities/doctype/address/address.py +++ b/erpnext/utilities/doctype/address/address.py @@ -21,7 +21,6 @@ from webnotes.model.doc import Document from webnotes import session, form, msgprint, errprint # ----------------------------------------------------------------------------------------- - class DocType: def __init__(self, doc, doclist=[]): self.doc = doc diff --git a/erpnext/utilities/doctype/address/listview.js b/erpnext/utilities/doctype/address/listview.js new file mode 100644 index 0000000000..325c059fc0 --- /dev/null +++ b/erpnext/utilities/doctype/address/listview.js @@ -0,0 +1,55 @@ +wn.doclistviews['Address'] = wn.views.ListView.extend({ + init: function(d) { + this._super(d) + this.fields = this.fields.concat([ + "`tabAddress`.customer_name", + "`tabAddress`.supplier", + "`tabAddress`.supplier_name", + "`tabAddress`.sales_partner", + "`tabAddress`.city", + "`tabAddress`.country", + "ifnull(`tabAddress`.is_shipping_address, 0) as is_shipping_address", + ]); + }, + + prepare_data: function(data) { + this._super(data); + + // prepare address + var address = [] + $.each(['city', 'country'], function(i, v) { + if(data[v]) address.push(data[v]); + }); + data.address = address.join(", "); + + // prepare shipping tag + if(data.is_shipping_address) { + data.shipping = 'Shipping'; + } + + + // prepare description + if(data.customer) { + data.description = (data.customer_name || data.customer); + data.contact_type = 'Customer'; + } else if (data.supplier) { + data.description = (data.supplier_name || data.supplier); + data.contact_type = 'Supplier'; + } else if (data.sales_partner) { + data.description = data.sales_partner; + data.contact_type = 'Sales Partner' + } else { + data.description = ''; + data.contact_type = ''; + } +}, + + columns: [ + {width: '3%', content: 'check'}, + {width: '20%', content: 'name'}, + {width: '15%', content: 'contact_type'}, + {width: '20%', content: 'description'}, + {width: '30%', content: 'address+shipping+tags', css: {'padding': '2px 0px'}}, + {width: '12%', content: 'modified', css: {'text-align': 'right', 'color':'#777'}} + ] +}); diff --git a/erpnext/utilities/doctype/contact/contact.py b/erpnext/utilities/doctype/contact/contact.py index 6b47b59e97..3b5131f6cb 100644 --- a/erpnext/utilities/doctype/contact/contact.py +++ b/erpnext/utilities/doctype/contact/contact.py @@ -21,7 +21,6 @@ from webnotes.model.doc import Document from webnotes import session, form, msgprint, errprint # ----------------------------------------------------------------------------------------- - class DocType: def __init__(self, doc, doclist=[]): self.doc = doc diff --git a/erpnext/utilities/doctype/contact/listview.js b/erpnext/utilities/doctype/contact/listview.js new file mode 100644 index 0000000000..bbf5bf855e --- /dev/null +++ b/erpnext/utilities/doctype/contact/listview.js @@ -0,0 +1,50 @@ +wn.doclistviews['Contact'] = wn.views.ListView.extend({ + init: function(d) { + this._super(d) + this.fields = this.fields.concat([ + "`tabContact`.first_name", + "`tabContact`.last_name", + "`tabContact`.customer", + "`tabContact`.customer_name", + "`tabContact`.supplier", + "`tabContact`.supplier_name", + "`tabContact`.sales_partner", + "`tabContact`.email_id", + ]); + }, + + prepare_data: function(data) { + this._super(data); + + // prepare fullname + data.fullname = (data.first_name || '') + + (data.last_name ? ' ' + data.last_name : ''); + if(!data.fullname) data.fullname = data.name; + data.fullname = repl("%(fullname)s\ + ", data); + + // prepare description + if(data.customer) { + data.description = (data.customer_name || data.customer); + data.contact_type = 'Customer'; + } else if (data.supplier) { + data.description = (data.supplier_name || data.supplier); + data.contact_type = 'Supplier'; + } else if (data.sales_partner) { + data.description = data.sales_partner; + data.contact_type = 'Sales Partner' + } else { + data.description = ''; + data.contact_type = ''; + } + }, + + columns: [ + {width: '3%', content: 'check'}, + {width: '20%', content: 'fullname'}, + {width: '15%', content: 'contact_type'}, + {width: '20%', content: 'description+tags'}, + {width: '30%', content: 'email_id'}, + {width: '12%', content:'modified', css: {'text-align': 'right', 'color':'#777'}} + ] +}); From 851b9c0aade9f8ca91771329261511a887a4860b Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Mon, 2 Jul 2012 20:25:26 +0530 Subject: [PATCH 13/13] address contact permissions --- .../july_2012/address_contact_perms.py | 11 ++ erpnext/patches/patch_list.py | 5 + erpnext/utilities/doctype/address/address.txt | 124 ++++++++++++++++-- erpnext/utilities/doctype/contact/contact.txt | 48 +++---- 4 files changed, 150 insertions(+), 38 deletions(-) create mode 100644 erpnext/patches/july_2012/address_contact_perms.py diff --git a/erpnext/patches/july_2012/address_contact_perms.py b/erpnext/patches/july_2012/address_contact_perms.py new file mode 100644 index 0000000000..1f14bd028f --- /dev/null +++ b/erpnext/patches/july_2012/address_contact_perms.py @@ -0,0 +1,11 @@ +def execute(): + import webnotes + webnotes.conn.sql("""\ + delete from `tabDocPerm` + where parent in ('Address', 'Contact')""") + webnotes.conn.commit() + + import webnotes.model.sync + webnotes.model.sync.sync('utilities', 'address') + webnotes.model.sync.sync('utilities', 'contact') + webnotes.conn.begin() \ No newline at end of file diff --git a/erpnext/patches/patch_list.py b/erpnext/patches/patch_list.py index 3a043b9e7e..82d7917dc4 100644 --- a/erpnext/patches/patch_list.py +++ b/erpnext/patches/patch_list.py @@ -472,4 +472,9 @@ patch_list = [ 'patch_file': 'reload_pr_po_mapper', 'description': "order date should be greater than equal to request date" }, + { + 'patch_module': 'patches.july_2012', + 'patch_file': 'address_contact_perms', + 'description': "sync address contact perms" + }, ] \ No newline at end of file diff --git a/erpnext/utilities/doctype/address/address.txt b/erpnext/utilities/doctype/address/address.txt index 56bbbe52a0..1ccfaa18f1 100644 --- a/erpnext/utilities/doctype/address/address.txt +++ b/erpnext/utilities/doctype/address/address.txt @@ -3,9 +3,9 @@ # These values are common in all dictionaries { - 'creation': '2012-03-27 14:36:45', + 'creation': '2012-07-02 19:57:47', 'docstatus': 0, - 'modified': '2012-03-27 14:36:45', + 'modified': '2012-07-02 20:24:15', 'modified_by': u'Administrator', 'owner': u'Administrator' }, @@ -24,7 +24,7 @@ 'search_fields': u'customer, supplier, sales_partner, country, state', 'section_style': u'Simple', 'show_in_menu': 0, - 'version': 43 + 'version': 1 }, # These values are common for all DocField @@ -38,17 +38,12 @@ # These values are common for all DocPerm { - 'cancel': 1, - 'create': 1, 'doctype': u'DocPerm', 'name': '__common__', 'parent': u'Address', 'parentfield': u'permissions', 'parenttype': u'DocType', - 'permlevel': 0, - 'read': 1, - 'role': u'All', - 'write': 1 + 'read': 1 }, # DocType, Address @@ -59,7 +54,116 @@ # DocPerm { - 'doctype': u'DocPerm' + 'cancel': 1, + 'create': 1, + 'doctype': u'DocPerm', + 'permlevel': 0, + 'role': u'System Manager', + 'write': 1 + }, + + # DocPerm + { + 'cancel': 1, + 'create': 1, + 'doctype': u'DocPerm', + 'permlevel': 0, + 'role': u'Sales Master Manager', + 'write': 1 + }, + + # DocPerm + { + 'cancel': 1, + 'create': 1, + 'doctype': u'DocPerm', + 'permlevel': 0, + 'role': u'Purchase Master Manager', + 'write': 1 + }, + + # DocPerm + { + 'cancel': 0, + 'create': 1, + 'doctype': u'DocPerm', + 'permlevel': 0, + 'role': u'Maintenance Manager', + 'write': 1 + }, + + # DocPerm + { + 'cancel': 0, + 'create': 1, + 'doctype': u'DocPerm', + 'permlevel': 0, + 'role': u'Accounts Manager', + 'write': 1 + }, + + # DocPerm + { + 'create': 1, + 'doctype': u'DocPerm', + 'permlevel': 0, + 'role': u'Sales Manager', + 'write': 1 + }, + + # DocPerm + { + 'create': 1, + 'doctype': u'DocPerm', + 'permlevel': 0, + 'role': u'Purchase Manager', + 'write': 1 + }, + + # DocPerm + { + 'create': 1, + 'doctype': u'DocPerm', + 'permlevel': 0, + 'role': u'Sales User', + 'write': 1 + }, + + # DocPerm + { + 'create': 1, + 'doctype': u'DocPerm', + 'permlevel': 0, + 'role': u'Purchase User', + 'write': 1 + }, + + # DocPerm + { + 'create': 1, + 'doctype': u'DocPerm', + 'permlevel': 0, + 'role': u'Maintenance User', + 'write': 1 + }, + + # DocPerm + { + 'create': 1, + 'doctype': u'DocPerm', + 'permlevel': 0, + 'role': u'Accounts User', + 'write': 1 + }, + + # DocPerm + { + 'cancel': 0, + 'create': 0, + 'doctype': u'DocPerm', + 'permlevel': 1, + 'role': u'All', + 'write': 0 }, # DocField diff --git a/erpnext/utilities/doctype/contact/contact.txt b/erpnext/utilities/doctype/contact/contact.txt index f385bd68d9..a4939c4d69 100644 --- a/erpnext/utilities/doctype/contact/contact.txt +++ b/erpnext/utilities/doctype/contact/contact.txt @@ -3,9 +3,9 @@ # These values are common in all dictionaries { - 'creation': '2012-03-27 14:36:46', + 'creation': '2012-07-02 19:57:48', 'docstatus': 0, - 'modified': '2012-03-27 14:36:46', + 'modified': '2012-07-02 20:24:17', 'modified_by': u'Administrator', 'owner': u'Administrator' }, @@ -26,7 +26,7 @@ 'server_code_error': u' ', 'show_in_menu': 0, 'subject': u'%(first_name)s %(last_name)s - Email: %(email_id)s | Contact: %(phone)s | Mobile: %(mobile_no)s', - 'version': 245 + 'version': 1 }, # These values are common for all DocField @@ -54,6 +54,16 @@ 'name': u'Contact' }, + # DocPerm + { + 'cancel': 1, + 'create': 1, + 'doctype': u'DocPerm', + 'permlevel': 0, + 'role': u'System Manager', + 'write': 1 + }, + # DocPerm { 'amend': 0, @@ -66,21 +76,6 @@ 'write': 1 }, - # DocPerm - { - 'doctype': u'DocPerm', - 'permlevel': 1, - 'role': u'All', - 'write': 1 - }, - - # DocPerm - { - 'doctype': u'DocPerm', - 'permlevel': 2, - 'role': u'All' - }, - # DocPerm { 'cancel': 1, @@ -91,16 +86,6 @@ 'write': 1 }, - # DocPerm - { - 'cancel': 1, - 'create': 1, - 'doctype': u'DocPerm', - 'permlevel': 0, - 'role': u'System Manager', - 'write': 1 - }, - # DocPerm { 'doctype': u'DocPerm', @@ -115,6 +100,13 @@ 'role': u'Purchase User' }, + # DocPerm + { + 'doctype': u'DocPerm', + 'permlevel': 1, + 'role': u'All' + }, + # DocField { 'colour': u'White:FFF',