[minor] [for territory] auto add default For Territory in a new Tax Master, Shipping Rule and Price List

This commit is contained in:
Anand Doshi 2013-07-15 18:09:43 +05:30
parent 4563ef3aea
commit 1ffc5b576c
4 changed files with 132 additions and 114 deletions

View File

@ -16,7 +16,8 @@
//--------- ONLOAD ------------- //--------- ONLOAD -------------
cur_frm.cscript.onload = function(doc, cdt, cdn) { cur_frm.cscript.onload = function(doc, cdt, cdn) {
// if(doc.doctype === "Sales Taxes and Charges Master")
erpnext.add_for_territory();
} }
cur_frm.cscript.refresh = function(doc, cdt, cdn) { cur_frm.cscript.refresh = function(doc, cdt, cdn) {

View File

@ -0,0 +1,5 @@
$.extend(cur_frm.cscript, {
onload: function() {
erpnext.add_for_territory();
}
});

View File

@ -39,5 +39,14 @@ $.extend(erpnext, {
cur_frm.toggle_display("company", false); cur_frm.toggle_display("company", false);
} }
} }
},
add_for_territory: function() {
if(cur_frm.doc.__islocal &&
wn.model.get_doclist(cur_frm.doc.doctype, cur_frm.doc.name).length === 1) {
var territory = wn.model.add_child(cur_frm.doc, "For Territory",
"valid_for_territories");
territory.territory = wn.defaults.get_default("territory");
} }
},
}); });

View File

@ -14,11 +14,13 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
cur_frm.cscript.onload = function() { $.extend(cur_frm.cscript, {
onload: function() {
cur_frm.cscript.show_item_prices(); cur_frm.cscript.show_item_prices();
} erpnext.add_for_territory();
},
cur_frm.cscript.refresh = function(doc, cdt, cdn) { refresh: function(doc) {
cur_frm.set_intro(""); cur_frm.set_intro("");
if(doc.__islocal) { if(doc.__islocal) {
cur_frm.toggle_display("item_prices_section", false); cur_frm.toggle_display("item_prices_section", false);
@ -27,9 +29,9 @@ cur_frm.cscript.refresh = function(doc, cdt, cdn) {
} else { } else {
cur_frm.cscript.show_item_prices(); cur_frm.cscript.show_item_prices();
} }
} },
cur_frm.cscript.show_item_prices = function() { show_item_prices: function() {
var item_price = wn.model.get("Item Price", {price_list_name: cur_frm.doc.name}); var item_price = wn.model.get("Item Price", {price_list_name: cur_frm.doc.name});
var show = item_price && item_price.length; var show = item_price && item_price.length;
@ -54,3 +56,4 @@ cur_frm.cscript.show_item_prices = function() {
</table>'; </table>';
$(out).appendTo($(cur_frm.fields_dict.item_prices.wrapper)); $(out).appendTo($(cur_frm.fields_dict.item_prices.wrapper));
} }
});