Rushabh Mehta | e67d1fb | 2013-08-05 14:59:54 +0530 | [diff] [blame] | 1 | // Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. |
| 2 | // License: GNU General Public License v3. See license.txt |
Anand Doshi | bdee6e0 | 2013-07-09 13:03:39 +0530 | [diff] [blame] | 3 | wn.provide("erpnext"); |
Anand Doshi | e65e621 | 2012-11-19 15:43:18 +0530 | [diff] [blame] | 4 | |
Anand Doshi | bdee6e0 | 2013-07-09 13:03:39 +0530 | [diff] [blame] | 5 | $.extend(erpnext, { |
| 6 | get_currency: function(company) { |
| 7 | if(!company && cur_frm) |
| 8 | company = cur_frm.doc.company; |
| 9 | if(company) |
Nabin Hait | 48a0bd3 | 2013-07-23 15:31:39 +0530 | [diff] [blame] | 10 | return wn.model.get_doc(":Company", company).default_currency || wn.boot.sysdefaults.currency; |
Anand Doshi | bdee6e0 | 2013-07-09 13:03:39 +0530 | [diff] [blame] | 11 | else |
| 12 | return wn.boot.sysdefaults.currency; |
| 13 | }, |
| 14 | |
| 15 | hide_naming_series: function() { |
| 16 | if(cur_frm.fields_dict.naming_series) { |
| 17 | cur_frm.toggle_display("naming_series", cur_frm.doc.__islocal?true:false); |
| 18 | } |
| 19 | }, |
| 20 | |
| 21 | hide_company: function() { |
| 22 | if(cur_frm.fields_dict.company) { |
| 23 | var companies = Object.keys(locals[":Company"]); |
| 24 | if(companies.length === 1) { |
| 25 | if(!cur_frm.doc.company) cur_frm.set_value("company", companies[0]); |
| 26 | cur_frm.toggle_display("company", false); |
| 27 | } |
| 28 | } |
Anand Doshi | 1ffc5b5 | 2013-07-15 18:09:43 +0530 | [diff] [blame] | 29 | }, |
| 30 | |
| 31 | add_for_territory: function() { |
| 32 | if(cur_frm.doc.__islocal && |
| 33 | wn.model.get_doclist(cur_frm.doc.doctype, cur_frm.doc.name).length === 1) { |
| 34 | var territory = wn.model.add_child(cur_frm.doc, "For Territory", |
| 35 | "valid_for_territories"); |
| 36 | territory.territory = wn.defaults.get_default("territory"); |
| 37 | } |
| 38 | }, |
Anand Doshi | bdee6e0 | 2013-07-09 13:03:39 +0530 | [diff] [blame] | 39 | }); |