[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

@@ -1,86 +0,0 @@
[
{
"creation": "2012-02-02 11:50:33",
"docstatus": 0,
"modified": "2013-04-16 12:26:28",
"modified_by": "Administrator",
"owner": "Administrator"
},
{
"doctype": "Table Mapper Detail",
"name": "__common__",
"parent": "Delivery Note-Packing Slip",
"parentfield": "table_mapper_details",
"parenttype": "DocType Mapper"
},
{
"doctype": "Field Mapper Detail",
"name": "__common__",
"parent": "Delivery Note-Packing Slip",
"parentfield": "field_mapper_details",
"parenttype": "DocType Mapper"
},
{
"doctype": "DocType Mapper",
"from_doctype": "Delivery Note",
"module": "Stock",
"name": "__common__",
"ref_doc_submitted": 0,
"to_doctype": "Packing Slip"
},
{
"doctype": "DocType Mapper",
"name": "Delivery Note-Packing Slip"
},
{
"doctype": "Field Mapper Detail",
"from_field": "name",
"map": "Yes",
"match_id": 0,
"to_field": "delivery_note"
},
{
"doctype": "Field Mapper Detail",
"from_field": "qty",
"map": "No",
"match_id": 1,
"to_field": "qty"
},
{
"doctype": "Field Mapper Detail",
"from_field": "naming_series",
"map": "No",
"match_id": 0,
"to_field": "naming_series"
},
{
"doctype": "Field Mapper Detail",
"from_field": "name",
"map": "Yes",
"match_id": 1,
"to_field": "dn_detail"
},
{
"doctype": "Field Mapper Detail",
"from_field": "eval: flt(obj.qty) - flt(obj.packed_qty)",
"map": "Yes",
"match_id": 1,
"to_field": "qty"
},
{
"doctype": "Table Mapper Detail",
"from_table": "Delivery Note",
"match_id": 0,
"to_table": "Packing Slip",
"validation_logic": "docstatus=0"
},
{
"doctype": "Table Mapper Detail",
"from_field": "delivery_note_details",
"from_table": "Delivery Note Item",
"match_id": 1,
"to_field": "item_details",
"to_table": "Packing Slip Item",
"validation_logic": "IFNULL(packed_qty, 0) < IFNULL(qty, 0)"
}
]

View File

@@ -1,132 +0,0 @@
[
{
"owner": "Administrator",
"docstatus": 0,
"creation": "2010-12-14 17:56:41",
"modified_by": "Administrator",
"modified": "2012-04-03 12:49:50"
},
{
"name": "__common__",
"parent": "Sales Invoice-Delivery Note",
"doctype": "Table Mapper Detail",
"parenttype": "DocType Mapper",
"parentfield": "table_mapper_details"
},
{
"name": "__common__",
"parent": "Sales Invoice-Delivery Note",
"doctype": "Field Mapper Detail",
"parenttype": "DocType Mapper",
"parentfield": "field_mapper_details"
},
{
"name": "__common__",
"to_doctype": "Delivery Note",
"module": "Stock",
"doctype": "DocType Mapper",
"ref_doc_submitted": 1,
"from_doctype": "Sales Invoice"
},
{
"name": "Sales Invoice-Delivery Note",
"doctype": "DocType Mapper"
},
{
"map": "Yes",
"match_id": 1,
"to_field": "qty",
"doctype": "Field Mapper Detail",
"from_field": "eval: flt(obj.qty) - flt(obj.delivered_qty)"
},
{
"map": "Yes",
"match_id": 1,
"to_field": "prevdoc_docname",
"doctype": "Field Mapper Detail",
"from_field": "parent"
},
{
"map": "Yes",
"match_id": 1,
"to_field": "prevdoc_doctype",
"doctype": "Field Mapper Detail",
"from_field": "parenttype"
},
{
"map": "Yes",
"match_id": 1,
"to_field": "prevdoc_detail_docname",
"doctype": "Field Mapper Detail",
"from_field": "name"
},
{
"map": "Yes",
"match_id": 1,
"to_field": "amount",
"doctype": "Field Mapper Detail",
"from_field": "eval: (flt(obj.qty) - flt(obj.delivered_qty)) * flt(obj.basic_rate)"
},
{
"map": "Yes",
"match_id": 1,
"to_field": "export_amount",
"doctype": "Field Mapper Detail",
"from_field": "eval: (flt(obj.qty) - flt(obj.delivered_qty)) * flt(obj.export_rate)"
},
{
"map": "No",
"match_id": 0,
"to_field": "naming_series",
"doctype": "Field Mapper Detail",
"from_field": "naming_series"
},
{
"map": "Yes",
"match_id": 0,
"to_field": "delivery_address",
"doctype": "Field Mapper Detail",
"from_field": "customer_address"
},
{
"map": "Yes",
"match_id": 1,
"to_field": "serial_no",
"doctype": "Field Mapper Detail",
"from_field": "serial_no"
},
{
"match_id": 0,
"doctype": "Table Mapper Detail",
"from_table": "Sales Invoice",
"to_table": "Delivery Note",
"validation_logic": "docstatus=1"
},
{
"match_id": 1,
"to_field": "delivery_note_details",
"doctype": "Table Mapper Detail",
"from_field": "entries",
"from_table": "Sales Invoice Item",
"to_table": "Delivery Note Item",
"validation_logic": "docstatus = 1"
},
{
"match_id": 2,
"to_field": "other_charges",
"doctype": "Table Mapper Detail",
"from_field": "other_charges",
"from_table": "Sales Taxes and Charges",
"to_table": "Sales Taxes and Charges",
"validation_logic": "name is not null"
},
{
"match_id": 3,
"to_field": "sales_team",
"doctype": "Table Mapper Detail",
"from_field": "sales_team",
"from_table": "Sales Team",
"to_table": "Sales Team",
"validation_logic": "name is not null"
}
]

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]