refactored javascript models

This commit is contained in:
Rushabh Mehta
2012-12-13 12:53:21 +05:30
parent 1b8a4cab26
commit 291449b6fb
33 changed files with 104 additions and 109 deletions

View File

@@ -51,14 +51,14 @@ cur_frm.cscript.load_defaults = function(doc, dt, dn, callback) {
if(!cur_frm.doc.__islocal) { return; }
doc = locals[doc.doctype][doc.name];
var fields_to_refresh = LocalDB.set_default_values(doc);
var fields_to_refresh = wn.model.set_default_values(doc);
if(fields_to_refresh) { refresh_many(fields_to_refresh); }
fields_to_refresh = null;
var children = getchildren(cur_frm.cscript.tname, doc.name, cur_frm.cscript.fname);
if(!children) { return; }
for(var i=0; i<children.length; i++) {
LocalDB.set_default_values(children[i]);
wn.model.set_default_values(children[i]);
}
refresh_field(cur_frm.cscript.fname);
cur_frm.cscript.load_taxes(doc, dt, dn, callback);

View File

@@ -122,9 +122,9 @@ cur_frm.cscript.get_last_purchase_rate = function(doc, cdt, cdn){
//========================= Make Purchase Receipt =======================================================
cur_frm.cscript['Make Purchase Receipt'] = function() {
n = createLocal('Purchase Receipt');
n = wn.model.make_new_doc_and_get_name('Purchase Receipt');
$c('dt_map', args={
'docs':compress_doclist([locals['Purchase Receipt'][n]]),
'docs':wn.model.compress([locals['Purchase Receipt'][n]]),
'from_doctype': cur_frm.doc.doctype,
'to_doctype':'Purchase Receipt',
'from_docname':cur_frm.doc.name,
@@ -137,9 +137,9 @@ cur_frm.cscript['Make Purchase Receipt'] = function() {
//========================== Make Purchase Invoice =====================================================
cur_frm.cscript['Make Purchase Invoice'] = function() {
n = createLocal('Purchase Invoice');
n = wn.model.make_new_doc_and_get_name('Purchase Invoice');
$c('dt_map', {
'docs':compress_doclist([locals['Purchase Invoice'][n]]),
'docs':wn.model.compress([locals['Purchase Invoice'][n]]),
'from_doctype':cur_frm.doc.doctype,
'to_doctype':'Purchase Invoice',
'from_docname': cur_frm.doc.name,
@@ -158,7 +158,7 @@ cur_frm.cscript['Stop Purchase Order'] = function() {
var check = confirm("Do you really want to STOP " + doc.name);
if (check) {
$c('runserverobj', args={'method':'update_status', 'arg': 'Stopped', 'docs': compress_doclist(make_doclist(doc.doctype, doc.name))}, function(r,rt) {
$c('runserverobj', args={'method':'update_status', 'arg': 'Stopped', 'docs': wn.model.compress(make_doclist(doc.doctype, doc.name))}, function(r,rt) {
cur_frm.refresh();
});
}
@@ -171,7 +171,7 @@ cur_frm.cscript['Unstop Purchase Order'] = function() {
var check = confirm("Do you really want to UNSTOP " + doc.name);
if (check) {
$c('runserverobj', args={'method':'update_status', 'arg': 'Submitted', 'docs': compress_doclist(make_doclist(doc.doctype, doc.name))}, function(r,rt) {
$c('runserverobj', args={'method':'update_status', 'arg': 'Submitted', 'docs': wn.model.compress(make_doclist(doc.doctype, doc.name))}, function(r,rt) {
cur_frm.refresh();
});
}

View File

@@ -86,9 +86,9 @@ cur_frm.cscript.qty = function(doc, cdt, cdn) {
// Make Purchase Order
cur_frm.cscript['Make Purchase Order'] = function() {
var doc = cur_frm.doc;
n = createLocal('Purchase Order');
n = wn.model.make_new_doc_and_get_name('Purchase Order');
$c('dt_map', args={
'docs':compress_doclist([locals['Purchase Order'][n]]),
'docs':wn.model.compress([locals['Purchase Order'][n]]),
'from_doctype':doc.doctype,
'to_doctype':'Purchase Order',
'from_docname':doc.name,
@@ -106,7 +106,7 @@ cur_frm.cscript['Stop Purchase Request'] = function() {
var check = confirm("Do you really want to STOP this Purchase Request?");
if (check) {
$c('runserverobj', args={'method':'update_status', 'arg': 'Stopped', 'docs': compress_doclist(make_doclist(doc.doctype, doc.name))}, function(r,rt) {
$c('runserverobj', args={'method':'update_status', 'arg': 'Stopped', 'docs': wn.model.compress(make_doclist(doc.doctype, doc.name))}, function(r,rt) {
cur_frm.refresh();
});
}
@@ -119,7 +119,7 @@ cur_frm.cscript['Unstop Purchase Request'] = function(){
var check = confirm("Do you really want to UNSTOP this Purchase Request?");
if (check) {
$c('runserverobj', args={'method':'update_status', 'arg': 'Submitted','docs': compress_doclist(make_doclist(doc.doctype, doc.name))}, function(r,rt) {
$c('runserverobj', args={'method':'update_status', 'arg': 'Submitted','docs': wn.model.compress(make_doclist(doc.doctype, doc.name))}, function(r,rt) {
cur_frm.refresh();
});
@@ -127,9 +127,9 @@ cur_frm.cscript['Unstop Purchase Request'] = function(){
}
cur_frm.cscript.make_supplier_quotation = function() {
var new_sq_name = createLocal("Supplier Quotation");
var new_sq_name = wn.model.make_new_doc_and_get_name("Supplier Quotation");
$c("dt_map", {
"docs": compress_doclist([locals['Supplier Quotation'][new_sq_name]]),
"docs": wn.model.compress([locals['Supplier Quotation'][new_sq_name]]),
"from_doctype": cur_frm.doc.doctype,
"to_doctype": "Supplier Quotation",
"from_docname": cur_frm.doc.name,

View File

@@ -79,7 +79,7 @@ cur_frm.cscript.make_contact = function() {
page_length: 2,
new_doctype: "Contact",
custom_new_doc: function(doctype) {
var contact = LocalDB.create('Contact');
var contact = wn.model.make_new_doc_and_get_name('Contact');
contact = locals['Contact'][contact];
contact.supplier = cur_frm.doc.name;
contact.supplier_name = cur_frm.doc.supplier_name;

View File

@@ -49,9 +49,9 @@ cur_frm.cscript.refresh = function(doc, dt, dn) {
}
cur_frm.cscript.make_purchase_order = function() {
var new_po_name = createLocal("Purchase Order");
var new_po_name = wn.model.make_new_doc_and_get_name("Purchase Order");
$c("dt_map", {
"docs": compress_doclist([locals['Purchase Order'][new_po_name]]),
"docs": wn.model.compress([locals['Purchase Order'][new_po_name]]),
"from_doctype": cur_frm.doc.doctype,
"to_doctype": "Purchase Order",
"from_docname": cur_frm.doc.name,