diff --git a/patches/august_2013/p01_hr_settings.py b/patches/august_2013/p01_hr_settings.py index 302611bb6f2..d34ef521494 100644 --- a/patches/august_2013/p01_hr_settings.py +++ b/patches/august_2013/p01_hr_settings.py @@ -1,6 +1,7 @@ # Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. # License: GNU General Public License v3. See license.txt +from __future__ import unicode_literals import webnotes def execute(): diff --git a/public/js/transaction.js b/public/js/transaction.js index 7a1dc0c6c45..67204f3a83d 100644 --- a/public/js/transaction.js +++ b/public/js/transaction.js @@ -32,6 +32,21 @@ erpnext.TransactionController = erpnext.stock.StockController.extend({ } }, + onload_post_render: function() { + if(this.frm.doc.__islocal && this.frm.doc.company && !this.frm.doc.customer) { + var me = this; + return this.frm.call({ + doc: this.frm.doc, + method: "onload_post_render", + freeze: true, + callback: function(r) { + // remove this call when using client side mapper + me.set_default_values(); + } + }); + } + }, + refresh: function() { this.frm.clear_custom_buttons(); erpnext.hide_naming_series(); @@ -44,6 +59,17 @@ erpnext.TransactionController = erpnext.stock.StockController.extend({ this.calculate_taxes_and_totals(); }, + set_default_values: function() { + $.each(wn.model.get_doclist(this.frm.doctype, this.frm.docname), function(i, doc) { + var updated = wn.model.set_default_values(doc); + if(doc.parentfield) { + refresh_field(doc.parentfield); + } else { + refresh_field(updated); + } + }); + }, + company: function() { if(this.frm.doc.company && this.frm.fields_dict.currency) { if(!this.frm.doc.currency) {