[mapper] removed old mapper from files and database

This commit is contained in:
Nabin Hait
2013-07-07 19:11:52 +05:30
parent 2b3ca41450
commit ed23cca9d3
21 changed files with 180 additions and 1021 deletions

View File

@@ -31,7 +31,8 @@ erpnext.stock.DeliveryNoteController = erpnext.selling.SellingController.extend(
if(flt(doc.per_billed, 2) < 100 && doc.docstatus==1) cur_frm.add_custom_button('Make Invoice', this.make_sales_invoice);
if(flt(doc.per_installed, 2) < 100 && doc.docstatus==1) cur_frm.add_custom_button('Make Installation Note', cur_frm.cscript['Make Installation Note']);
if(flt(doc.per_installed, 2) < 100 && doc.docstatus==1)
cur_frm.add_custom_button('Make Installation Note', this.make_installation_note);
if (doc.docstatus==1) cur_frm.add_custom_button('Send SMS', cur_frm.cscript.send_sms);
@@ -59,7 +60,15 @@ erpnext.stock.DeliveryNoteController = erpnext.selling.SellingController.extend(
method: "stock.doctype.delivery_note.delivery_note.make_sales_invoice",
source_name: cur_frm.doc.name
})
},
make_installation_note: function() {
wn.model.open_mapped_doc({
method: "stock.doctype.delivery_note.delivery_note.make_installation_note",
source_name: cur_frm.doc.name
});
}
});
// for backward compatibility: combine new and previous states
@@ -114,40 +123,6 @@ cur_frm.fields_dict['transporter_name'].get_query = function(doc) {
return 'SELECT DISTINCT `tabSupplier`.`name` FROM `tabSupplier` WHERE `tabSupplier`.supplier_type = "transporter" AND `tabSupplier`.docstatus != 2 AND `tabSupplier`.%(key)s LIKE "%s" ORDER BY `tabSupplier`.`name` LIMIT 50';
}
cur_frm.cscript['Make Sales Invoice'] = function() {
var doc = cur_frm.doc
n = wn.model.make_new_doc_and_get_name('Sales Invoice');
$c('dt_map', args={
'docs':wn.model.compress([locals['Sales Invoice'][n]]),
'from_doctype':doc.doctype,
'to_doctype':'Sales Invoice',
'from_docname':doc.name,
'from_to_list':"[['Delivery Note','Sales Invoice'],['Delivery Note Item','Sales Invoice Item'],['Sales Taxes and Charges','Sales Taxes and Charges'],['Sales Team','Sales Team']]"
}, function(r,rt) {
loaddoc('Sales Invoice', n);
}
);
}
cur_frm.cscript['Make Installation Note'] = function() {
var doc = cur_frm.doc;
if(doc.per_installed < 99.99){
n = wn.model.make_new_doc_and_get_name('Installation Note');
$c('dt_map', args={
'docs':wn.model.compress([locals['Installation Note'][n]]),
'from_doctype':doc.doctype,
'to_doctype':'Installation Note',
'from_docname':doc.name,
'from_to_list':"[['Delivery Note','Installation Note'],['Delivery Note Item','Installation Note Item']]"
}, function(r,rt) {
loaddoc('Installation Note', n);
}
);
}
else if(doc.per_installed >= 100)
msgprint("Item installation is already completed")
}
cur_frm.cscript['Make Packing Slip'] = function() {
n = wn.model.make_new_doc_and_get_name('Packing Slip');
ps = locals["Packing Slip"][n];

View File

@@ -22,6 +22,8 @@ from webnotes.model.bean import getlist
from webnotes.model.code import get_obj
from webnotes import msgprint, _
import webnotes.defaults
from webnotes.model.mapper import get_mapped_doclist
sql = webnotes.conn.sql
@@ -365,9 +367,7 @@ class DocType(SellingController):
make_gl_entries(gl_entries, cancel=(self.doc.docstatus == 2))
@webnotes.whitelist()
def make_sales_invoice(source_name, target_doclist=None):
from webnotes.model.mapper import get_mapped_doclist
def make_sales_invoice(source_name, target_doclist=None):
def update_item(obj, target, source_parent):
target.export_amount = flt(obj.amount) - flt(obj.billed_amt)
target.amount = target.export_amount / flt(source_parent.conversion_rate)
@@ -407,4 +407,35 @@ def make_sales_invoice(source_name, target_doclist=None):
}
}, target_doclist, update_accounts)
return [d.fields for d in doclist]
@webnotes.whitelist()
def make_installation_note(source_name, target_doclist=None):
def update_item(obj, target, source_parent):
target.qty = flt(obj.qty) - flt(obj.installed_qty)
doclist = get_mapped_doclist("Delivery Note", source_name, {
"Delivery Note": {
"doctype": "Installation Note Item",
"field_map": {
"name": "delivery_note_no",
"posting_date": "prevdoc_date"
},
"validation": {
"docstatus": ["=", 1]
}
},
"Delivery Note Item": {
"doctype": "Installation Note Item",
"field_map": {
"name": "prevdoc_detail_docname",
"parent": "prevdoc_docname",
"parenttype": "prevdoc_doctype",
"serial_no": "serial_no"
},
"postprocess": update_item,
"condition": lambda doc: doc.installed_qty < doc.qty
}
}, target_doclist)
return [d.fields for d in doclist]