From 84d73103f8c0351aeac5664c9a49c473cea51a86 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Tue, 14 Feb 2012 15:13:21 +0530 Subject: [PATCH 1/4] sales team mapping issue in SO-DN and SO-RV --- .../doctype/receivable_voucher/receivable_voucher.js | 9 ++++++--- erpnext/stock/doctype/delivery_note/delivery_note.js | 7 ++++--- erpnext/utilities/transaction_base.py | 7 ++++--- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/erpnext/accounts/doctype/receivable_voucher/receivable_voucher.js b/erpnext/accounts/doctype/receivable_voucher/receivable_voucher.js index aa12ab88a4..386f4620d0 100644 --- a/erpnext/accounts/doctype/receivable_voucher/receivable_voucher.js +++ b/erpnext/accounts/doctype/receivable_voucher/receivable_voucher.js @@ -38,7 +38,7 @@ cur_frm.cscript.onload_post_render = function(doc, dt, dn) { 'load_default_accounts','', function(r,rt) { refresh_field('entries'); - cur_frm.cscript.customer(doc,dt,dn); + cur_frm.cscript.customer(doc,dt,dn,onload=true); } ); } @@ -137,18 +137,21 @@ cur_frm.cscript.warehouse = function(doc, cdt , cdn) { //Customer -cur_frm.cscript.customer = function(doc,dt,dn) { +cur_frm.cscript.customer = function(doc,dt,dn,onload) { var callback = function(r,rt) { var doc = locals[cur_frm.doctype][cur_frm.docname]; get_server_fields('get_debit_to','','',doc, dt, dn, 0); cur_frm.refresh(); } + var args = onload ? 'onload':'' + if(doc.customer) $c_obj(make_doclist(doc.doctype, doc.name), 'get_default_customer_address', args, callback); - if(doc.customer) $c_obj(make_doclist(doc.doctype, doc.name), 'get_default_customer_address', '', callback); if(doc.customer) unhide_field(['customer_address','contact_person','customer_name','address_display','contact_display','contact_mobile','contact_email','territory','customer_group']); } + + cur_frm.cscript.customer_address = cur_frm.cscript.contact_person = function(doc,dt,dn) { if(doc.customer) get_server_fields('get_customer_address', JSON.stringify({customer: doc.customer, address: doc.customer_address, contact: doc.contact_person}),'', doc, dt, dn, 1); } diff --git a/erpnext/stock/doctype/delivery_note/delivery_note.js b/erpnext/stock/doctype/delivery_note/delivery_note.js index b6329c50d3..d9f479504a 100644 --- a/erpnext/stock/doctype/delivery_note/delivery_note.js +++ b/erpnext/stock/doctype/delivery_note/delivery_note.js @@ -61,12 +61,13 @@ cur_frm.cscript.refresh = function(doc, cdt, cdn) { //customer -cur_frm.cscript.customer = function(doc,dt,dn) { +cur_frm.cscript.customer = function(doc,dt,dn,onload) { var callback = function(r,rt) { var doc = locals[cur_frm.doctype][cur_frm.docname]; cur_frm.refresh(); } - if(doc.customer) $c_obj(make_doclist(doc.doctype, doc.name), 'get_default_customer_shipping_address', '', callback); + var args = onload ? 'onload':'' + if(doc.customer) $c_obj(make_doclist(doc.doctype, doc.name), 'get_default_customer_shipping_address', args, callback); if(doc.customer) unhide_field(['customer_address','contact_person','customer_name','address_display','contact_display','contact_mobile','contact_email','territory','customer_group','shipping_address']); } @@ -112,7 +113,7 @@ cur_frm.cscript['Get Items'] = function(doc,dt,dn) { cur_frm.cscript.pull_item_details_onload = function(doc,dt,dn){ var callback = function(r,rt){ refresh_field('delivery_note_details'); - cur_frm.cscript.customer(doc,dt,dn); + cur_frm.cscript.customer(doc,dt,dn,onload=true); } $c_obj(make_doclist(dt,dn),'set_item_details','',callback); } diff --git a/erpnext/utilities/transaction_base.py b/erpnext/utilities/transaction_base.py index 7979036171..7cb7479cec 100644 --- a/erpnext/utilities/transaction_base.py +++ b/erpnext/utilities/transaction_base.py @@ -19,7 +19,8 @@ class TransactionBase: self.doc.contact_mobile = contact_mobile or '' self.get_customer_details(self.doc.customer) - self.get_sales_person(self.doc.customer) + if args != 'onload': + self.get_sales_person(self.doc.customer) # Get Customer Default Shipping Address - first load # ----------------------- @@ -34,8 +35,8 @@ class TransactionBase: self.doc.contact_mobile = contact_mobile or '' self.get_customer_details(self.doc.customer) - if self.doc.doctype != 'Quotation': - self.get_sales_person(self.doc.customer) + if self.doc.doctype != 'Quotation' and args != 'onload': + self.get_sales_person(self.doc.customer) # Get Customer Address # ----------------------- From 3d794a682d91c20a77d480c3a3a8c02be569e07b Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Tue, 14 Feb 2012 15:25:11 +0530 Subject: [PATCH 2/4] required by date should be mapped in indent-po --- .../Indent-Purchase Order.txt | 118 ++++++++++-------- 1 file changed, 63 insertions(+), 55 deletions(-) diff --git a/erpnext/buying/DocType Mapper/Indent-Purchase Order/Indent-Purchase Order.txt b/erpnext/buying/DocType Mapper/Indent-Purchase Order/Indent-Purchase Order.txt index fe49f4901e..fa9ab061b8 100644 --- a/erpnext/buying/DocType Mapper/Indent-Purchase Order/Indent-Purchase Order.txt +++ b/erpnext/buying/DocType Mapper/Indent-Purchase Order/Indent-Purchase Order.txt @@ -5,130 +5,138 @@ { 'creation': '2010-08-08 17:09:34', 'docstatus': 0, - 'modified': '2011-09-15 15:04:42', - 'modified_by': 'Administrator', - 'owner': 'Administrator' + 'modified': '2012-02-14 15:21:20', + 'modified_by': u'Administrator', + 'owner': u'Administrator' }, # These values are common for all Table Mapper Detail { - 'doctype': 'Table Mapper Detail', + 'doctype': u'Table Mapper Detail', 'name': '__common__', - 'parent': 'Indent-Purchase Order', - 'parentfield': 'table_mapper_details', - 'parenttype': 'DocType Mapper' + 'parent': u'Indent-Purchase Order', + 'parentfield': u'table_mapper_details', + 'parenttype': u'DocType Mapper' }, # These values are common for all Field Mapper Detail { - 'doctype': 'Field Mapper Detail', - 'map': 'Yes', + 'doctype': u'Field Mapper Detail', + 'map': u'Yes', 'name': '__common__', - 'parent': 'Indent-Purchase Order', - 'parentfield': 'field_mapper_details', - 'parenttype': 'DocType Mapper' + 'parent': u'Indent-Purchase Order', + 'parentfield': u'field_mapper_details', + 'parenttype': u'DocType Mapper' }, # These values are common for all DocType Mapper { - 'doctype': 'DocType Mapper', - 'from_doctype': 'Indent', - 'module': 'Buying', + 'doctype': u'DocType Mapper', + 'from_doctype': u'Indent', + 'module': u'Buying', 'name': '__common__', 'ref_doc_submitted': 1, - 'to_doctype': 'Purchase Order' + 'to_doctype': u'Purchase Order' }, # DocType Mapper, Indent-Purchase Order { - 'doctype': 'DocType Mapper', - 'name': 'Indent-Purchase Order' + 'doctype': u'DocType Mapper', + 'name': u'Indent-Purchase Order' }, # Field Mapper Detail { - 'checking_operator': '=', - 'doctype': 'Field Mapper Detail', - 'from_field': 'company', + 'checking_operator': u'=', + 'doctype': u'Field Mapper Detail', + 'from_field': u'company', 'match_id': 0, - 'to_field': 'company' + 'to_field': u'company' }, # Field Mapper Detail { - 'doctype': 'Field Mapper Detail', - 'from_field': 'parenttype', + 'doctype': u'Field Mapper Detail', + 'from_field': u'parenttype', 'match_id': 1, - 'to_field': 'prevdoc_doctype' + 'to_field': u'prevdoc_doctype' }, # Field Mapper Detail { - 'doctype': 'Field Mapper Detail', - 'from_field': 'parent', + 'doctype': u'Field Mapper Detail', + 'from_field': u'parent', 'match_id': 1, - 'to_field': 'prevdoc_docname' + 'to_field': u'prevdoc_docname' }, # Field Mapper Detail { - 'doctype': 'Field Mapper Detail', - 'from_field': 'name', + 'doctype': u'Field Mapper Detail', + 'from_field': u'name', 'match_id': 1, - 'to_field': 'prevdoc_detail_docname' + 'to_field': u'prevdoc_detail_docname' }, # Field Mapper Detail { - 'doctype': 'Field Mapper Detail', - 'from_field': 'uom', + 'doctype': u'Field Mapper Detail', + 'from_field': u'uom', 'match_id': 1, - 'to_field': 'stock_uom' + 'to_field': u'stock_uom' }, # Field Mapper Detail { - 'doctype': 'Field Mapper Detail', - 'from_field': 'eval:flt(1)', + 'doctype': u'Field Mapper Detail', + 'from_field': u'eval:flt(1)', 'match_id': 1, - 'to_field': 'conversion_factor' + 'to_field': u'conversion_factor' }, # Field Mapper Detail { - 'doctype': 'Field Mapper Detail', - 'from_field': 'eval:flt(obj.qty) - flt(obj.ordered_qty)', + 'doctype': u'Field Mapper Detail', + 'from_field': u'eval:flt(obj.qty) - flt(obj.ordered_qty)', 'match_id': 1, - 'to_field': 'stock_qty' + 'to_field': u'stock_qty' }, # Field Mapper Detail { - 'doctype': 'Field Mapper Detail', - 'from_field': 'eval:flt(obj.qty) - flt(obj.ordered_qty)', + 'doctype': u'Field Mapper Detail', + 'from_field': u'eval:flt(obj.qty) - flt(obj.ordered_qty)', 'match_id': 1, - 'to_field': 'qty' + 'to_field': u'qty' + }, + + # Field Mapper Detail + { + 'doctype': u'Field Mapper Detail', + 'from_field': u'schedule_date', + 'match_id': 1, + 'to_field': u'schedule_date' }, # Table Mapper Detail { - 'doctype': 'Table Mapper Detail', - 'from_table': 'Indent', + 'doctype': u'Table Mapper Detail', + 'from_table': u'Indent', 'match_id': 0, - 'reference_key': 'prevdoc_docname', - 'to_table': 'Purchase Order', - 'validation_logic': 'docstatus = 1' + 'reference_key': u'prevdoc_docname', + 'to_table': u'Purchase Order', + 'validation_logic': u'docstatus = 1' }, # Table Mapper Detail { - 'doctype': 'Table Mapper Detail', - 'from_field': 'indent_details', - 'from_table': 'Indent Detail', + 'doctype': u'Table Mapper Detail', + 'from_field': u'indent_details', + 'from_table': u'Indent Detail', 'match_id': 1, - 'reference_doctype_key': 'prevdoc_doctype', - 'to_field': 'po_details', - 'to_table': 'PO Detail', - 'validation_logic': 'qty > ifnull(ordered_qty,0) and docstatus =1' + 'reference_doctype_key': u'prevdoc_doctype', + 'to_field': u'po_details', + 'to_table': u'PO Detail', + 'validation_logic': u'qty > ifnull(ordered_qty,0) and docstatus =1' } ] \ No newline at end of file From 75ef7c7a897f2584cb9387f0928abb13663e5159 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Tue, 14 Feb 2012 16:08:22 +0530 Subject: [PATCH 3/4] def val of is_subcontracted is NO --- erpnext/patches/jan_mar_2012/subcon_default_val.py | 7 +++++++ erpnext/patches/patch_list.py | 5 +++++ 2 files changed, 12 insertions(+) create mode 100644 erpnext/patches/jan_mar_2012/subcon_default_val.py diff --git a/erpnext/patches/jan_mar_2012/subcon_default_val.py b/erpnext/patches/jan_mar_2012/subcon_default_val.py new file mode 100644 index 0000000000..c0bee4c97b --- /dev/null +++ b/erpnext/patches/jan_mar_2012/subcon_default_val.py @@ -0,0 +1,7 @@ +def execute(): + import webnotes + webnotes.conn.sql(""" + update `tabDocField` set `default` = 'No' + where parent in ('Purchase Order', 'Purchase Receipt') + and fieldname = 'is_subcontracted' + """) diff --git a/erpnext/patches/patch_list.py b/erpnext/patches/patch_list.py index cbe10c793e..94300381ce 100644 --- a/erpnext/patches/patch_list.py +++ b/erpnext/patches/patch_list.py @@ -74,5 +74,10 @@ patch_list = [ 'patch_module': 'patches.jan_mar_2012', 'patch_file': 'account_type_patch', 'description': 'mentioed account type for some tax accounts' + }, + { + 'patch_module': 'patches.jan_mar_2012', + 'patch_file': 'subcon_default_val', + 'description': 'Default value of is_subcontracted in PO, PR is No' } ] From 737c2f9432e8a49aefbf68589c2aeee460b6e0ea Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Tue, 14 Feb 2012 16:16:13 +0530 Subject: [PATCH 4/4] fix in login as --- erpnext/startup/event_handlers.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/erpnext/startup/event_handlers.py b/erpnext/startup/event_handlers.py index d9fbbedfd3..690ca64c39 100644 --- a/erpnext/startup/event_handlers.py +++ b/erpnext/startup/event_handlers.py @@ -11,6 +11,9 @@ def on_login(login_manager): try: import server_tools.gateway_utils server_tools.gateway_utils.check_login(login_manager.user) + + login_as(login_manager) + except ImportError: pass @@ -65,3 +68,27 @@ def get_letter_heads(): ret = webnotes.conn.sql("""select name, content from `tabLetter Head` where ifnull(disabled,0)=0""") return dict(ret) + + +def login_as(login_manager): + """ + Login as functionality -- allows signin from signin.erpnext.com + """ + # login as user + user = webnotes.form.getvalue('login_as') + if user: + if isinstance(webnotes.session, dict): + webnotes.session['user'] = user + else: + webnotes.session = {'user': user} + + login_manager.user = user + + if hasattr(webnotes.defs, 'validate_ip'): + msg = getattr(webnotes.defs, 'validate_ip')() + if msg: webnotes.msgprint(msg, raise_exception=1) + + # alisaing here... so check if the user is disabled + if not webnotes.conn.sql("select ifnull(enabled,0) from tabProfile where name=%s", user)[0][0]: + # throw execption + webnotes.msgprint("Authentication Failed", raise_exception=1)