mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-20 21:49:18 +00:00
[mapper]
This commit is contained in:
@@ -29,7 +29,7 @@ erpnext.stock.DeliveryNoteController = erpnext.selling.SellingController.extend(
|
||||
refresh: function(doc, dt, dn) {
|
||||
this._super();
|
||||
|
||||
if(flt(doc.per_billed, 2) < 100 && doc.docstatus==1) cur_frm.add_custom_button('Make Invoice', cur_frm.cscript['Make Sales Invoice']);
|
||||
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']);
|
||||
|
||||
@@ -45,6 +45,20 @@ erpnext.stock.DeliveryNoteController = erpnext.selling.SellingController.extend(
|
||||
var aii_enabled = cint(sys_defaults.auto_inventory_accounting)
|
||||
cur_frm.fields_dict[cur_frm.cscript.fname].grid.set_column_disp("expense_account", aii_enabled);
|
||||
cur_frm.fields_dict[cur_frm.cscript.fname].grid.set_column_disp("cost_center", aii_enabled);
|
||||
},
|
||||
|
||||
get_items: function() {
|
||||
wn.model.map_current_doc({
|
||||
method: "selling.doctype.sales_order.sales_order.make_delivery_note",
|
||||
source_name: cur_frm.doc.sales_order_no,
|
||||
})
|
||||
},
|
||||
|
||||
make_sales_invoice: function() {
|
||||
wn.model.open_mapped_doc({
|
||||
method: "stock.doctype.delivery_note.delivery_note.make_sales_invoice",
|
||||
source_name: cur_frm.doc.name
|
||||
})
|
||||
}
|
||||
});
|
||||
|
||||
@@ -55,16 +69,6 @@ cur_frm.cscript.customer_address = cur_frm.cscript.contact_person = function(doc
|
||||
if(doc.customer) get_server_fields('get_customer_address', JSON.stringify({customer: doc.customer, address: doc.customer_address, contact: doc.contact_person}),'', doc, dt, dn, 1);
|
||||
}
|
||||
|
||||
|
||||
cur_frm.cscript.get_items = function(doc,dt,dn) {
|
||||
wn.model.map_current_doc({
|
||||
method: "selling.doctype.sales_order.sales_order.make_delivery_note",
|
||||
source_name: cur_frm.doc.sales_order_no,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
//================ create new contact ============================================================================
|
||||
cur_frm.cscript.new_contact = function(){
|
||||
tn = wn.model.make_new_doc_and_get_name('Contact');
|
||||
locals['Contact'][tn].is_customer = 1;
|
||||
|
||||
@@ -363,3 +363,48 @@ class DocType(SellingController):
|
||||
if gl_entries:
|
||||
from accounts.general_ledger import make_gl_entries
|
||||
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 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)
|
||||
target.qty = obj.basic_rate and target.amount / flt(obj.basic_rate) or obj.qty
|
||||
|
||||
def update_accounts(source, target):
|
||||
si = webnotes.bean(target)
|
||||
si.run_method("update_accounts")
|
||||
|
||||
doclist = get_mapped_doclist("Delivery Note", source_name, {
|
||||
"Delivery Note": {
|
||||
"doctype": "Sales Invoice",
|
||||
"validation": {
|
||||
"docstatus": ["=", 1]
|
||||
}
|
||||
},
|
||||
"Delivery Note Item": {
|
||||
"doctype": "Sales Invoice Item",
|
||||
"field_map": {
|
||||
"name": "dn_detail",
|
||||
"parent": "delivery_note",
|
||||
"prevdoc_detail_docname": "so_detail",
|
||||
"prevdoc_docname": "sales_order",
|
||||
"serial_no": "serial_no"
|
||||
},
|
||||
"postprocess": update_item,
|
||||
"condition": lambda doc: doc.amount==0 or doc.billed_amt < doc.export_amount
|
||||
},
|
||||
"Sales Taxes and Charges": {
|
||||
"doctype": "Sales Taxes and Charges",
|
||||
},
|
||||
"Sales Team": {
|
||||
"doctype": "Sales Team",
|
||||
"field_map": {
|
||||
"incentives": "incentives"
|
||||
}
|
||||
}
|
||||
}, target_doclist, update_accounts)
|
||||
|
||||
return [d.fields for d in doclist]
|
||||
@@ -2,7 +2,7 @@
|
||||
{
|
||||
"creation": "2013-05-24 19:29:09",
|
||||
"docstatus": 0,
|
||||
"modified": "2013-07-05 14:34:50",
|
||||
"modified": "2013-07-06 19:04:46",
|
||||
"modified_by": "Administrator",
|
||||
"owner": "Administrator"
|
||||
},
|
||||
@@ -34,7 +34,6 @@
|
||||
"parent": "Delivery Note",
|
||||
"parentfield": "permissions",
|
||||
"parenttype": "DocType",
|
||||
"permlevel": 0,
|
||||
"read": 1,
|
||||
"report": 1
|
||||
},
|
||||
@@ -401,7 +400,6 @@
|
||||
"hidden": 0,
|
||||
"label": "Get Items",
|
||||
"oldfieldtype": "Button",
|
||||
"options": "pull_sales_order_details",
|
||||
"print_hide": 1,
|
||||
"read_only": 0
|
||||
},
|
||||
@@ -1127,39 +1125,83 @@
|
||||
"cancel": 1,
|
||||
"create": 1,
|
||||
"doctype": "DocPerm",
|
||||
"permlevel": 0,
|
||||
"role": "Material User",
|
||||
"submit": 1,
|
||||
"write": 1
|
||||
},
|
||||
{
|
||||
"amend": 0,
|
||||
"cancel": 0,
|
||||
"create": 0,
|
||||
"doctype": "DocPerm",
|
||||
"permlevel": 1,
|
||||
"role": "Material User",
|
||||
"submit": 0,
|
||||
"write": 0
|
||||
},
|
||||
{
|
||||
"amend": 1,
|
||||
"cancel": 1,
|
||||
"create": 1,
|
||||
"doctype": "DocPerm",
|
||||
"permlevel": 0,
|
||||
"role": "Material Manager",
|
||||
"submit": 1,
|
||||
"write": 1
|
||||
},
|
||||
{
|
||||
"amend": 0,
|
||||
"cancel": 0,
|
||||
"create": 0,
|
||||
"doctype": "DocPerm",
|
||||
"permlevel": 1,
|
||||
"role": "Material Manager",
|
||||
"submit": 0,
|
||||
"write": 0
|
||||
},
|
||||
{
|
||||
"amend": 1,
|
||||
"cancel": 1,
|
||||
"create": 1,
|
||||
"doctype": "DocPerm",
|
||||
"permlevel": 0,
|
||||
"role": "Sales User",
|
||||
"submit": 1,
|
||||
"write": 1
|
||||
},
|
||||
{
|
||||
"amend": 0,
|
||||
"cancel": 0,
|
||||
"create": 0,
|
||||
"doctype": "DocPerm",
|
||||
"permlevel": 1,
|
||||
"role": "Sales User",
|
||||
"submit": 0,
|
||||
"write": 0
|
||||
},
|
||||
{
|
||||
"cancel": 0,
|
||||
"create": 0,
|
||||
"doctype": "DocPerm",
|
||||
"permlevel": 0,
|
||||
"role": "Accounts User",
|
||||
"submit": 0,
|
||||
"write": 0
|
||||
},
|
||||
{
|
||||
"amend": 0,
|
||||
"cancel": 0,
|
||||
"create": 0,
|
||||
"doctype": "DocPerm",
|
||||
"permlevel": 1,
|
||||
"role": "Accounts User",
|
||||
"submit": 0
|
||||
},
|
||||
{
|
||||
"doctype": "DocPerm",
|
||||
"match": "customer_name",
|
||||
"permlevel": 0,
|
||||
"role": "Customer"
|
||||
}
|
||||
]
|
||||
@@ -360,7 +360,7 @@ def make_purchase_invoice(source_name, target_doclist=None):
|
||||
"purchase_rate": "rate"
|
||||
},
|
||||
"postprocess": update_item,
|
||||
"condition": lambda doc: doc.amount==0 or doc.billed_amt < doc.amount
|
||||
"condition": lambda doc: doc.amount==0 or doc.billed_amt < doc.import_amount
|
||||
},
|
||||
"Purchase Taxes and Charges": {
|
||||
"doctype": "Purchase Taxes and Charges",
|
||||
|
||||
Reference in New Issue
Block a user