Merge branch 'responsive' of git://github.com/webnotes/erpnext into responsive
This commit is contained in:
commit
3ccfb028fe
@ -203,21 +203,10 @@ cur_frm.cscript['Make Material Request'] = function() {
|
||||
|
||||
|
||||
cur_frm.cscript['Make Delivery Note'] = function() {
|
||||
var doc = cur_frm.doc;
|
||||
if (doc.docstatus == 1) {
|
||||
n = wn.model.make_new_doc_and_get_name("Delivery Note");
|
||||
$c('dt_map', args={
|
||||
'docs':wn.model.compress([locals["Delivery Note"][n]]),
|
||||
'from_doctype':'Sales Order',
|
||||
'to_doctype':'Delivery Note',
|
||||
'from_docname':doc.name,
|
||||
'from_to_list':"[['Sales Order', 'Delivery Note'], ['Sales Order Item', 'Delivery Note Item'],['Sales Taxes and Charges','Sales Taxes and Charges'],['Sales Team','Sales Team']]"
|
||||
}
|
||||
, function(r,rt) {
|
||||
loaddoc("Delivery Note", n);
|
||||
}
|
||||
);
|
||||
}
|
||||
wn.model.open_mapped_doc({
|
||||
method: "selling.doctype.sales_order.sales_order.make_delivery_note",
|
||||
source_name: cur_frm.doc.name
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
|
@ -405,4 +405,45 @@ def make_material_request(source_name, target_doclist=None):
|
||||
}, target_doclist, postprocess)
|
||||
|
||||
return [d.fields for d in doclist]
|
||||
|
||||
|
||||
@webnotes.whitelist()
|
||||
def make_delivery_note(source_name, target_doclist=None):
|
||||
from webnotes.model.mapper import get_mapped_doclist
|
||||
|
||||
def update_item(obj, target):
|
||||
target.amount = (flt(obj.qty) - flt(obj.delivered_qty)) * flt(obj.basic_rate)
|
||||
target.export_amount = (flt(obj.qty) - flt(obj.delivered_qty)) * flt(obj.export_rate)
|
||||
target.qty = flt(obj.qty) - flt(obj.delivered_qty)
|
||||
|
||||
doclist = get_mapped_doclist("Sales Order", source_name, {
|
||||
"Sales Order": {
|
||||
"doctype": "Delivery Note",
|
||||
"field_map": {
|
||||
"name": "sales_order_no",
|
||||
"shipping_address": "address_display",
|
||||
"shipping_address_name": "customer_address",
|
||||
},
|
||||
"validation": {
|
||||
"docstatus": ["=", 1]
|
||||
}
|
||||
},
|
||||
"Sales Order Item": {
|
||||
"doctype": "Delivery Note Item",
|
||||
"field_map": {
|
||||
"export_rate": "export_rate",
|
||||
"name": "prevdoc_detail_docname",
|
||||
"parent": "prevdoc_docname",
|
||||
"parenttype": "prevdoc_doctype",
|
||||
"reserved_warehouse": "warehouse"
|
||||
},
|
||||
"postprocess": update_item
|
||||
},
|
||||
"Sales Taxes and Charges": {
|
||||
"doctype": "Sales Taxes and Charges",
|
||||
},
|
||||
"Sales Team": {
|
||||
"doctype": "Sales Team",
|
||||
}
|
||||
}, target_doclist)
|
||||
|
||||
return [d.fields for d in doclist]
|
||||
|
@ -6,16 +6,33 @@ class TestSalesOrder(unittest.TestCase):
|
||||
def test_make_material_request(self):
|
||||
from selling.doctype.sales_order.sales_order import make_material_request
|
||||
|
||||
so = webnotes.bean(copy=test_records[0]).insert()
|
||||
|
||||
self.assertRaises(webnotes.ValidationError, make_material_request,
|
||||
"_T-Sales Order-00001")
|
||||
so.doc.name)
|
||||
|
||||
sales_order = webnotes.bean("Sales Order", "_T-Sales Order-00001")
|
||||
sales_order = webnotes.bean("Sales Order", so.doc.name)
|
||||
sales_order.submit()
|
||||
mr = make_material_request("_T-Sales Order-00001")
|
||||
mr = make_material_request(so.doc.name)
|
||||
|
||||
self.assertEquals(mr[0]["material_request_type"], "Purchase")
|
||||
self.assertEquals(len(mr), len(sales_order.doclist))
|
||||
|
||||
|
||||
def test_make_delivery_note(self):
|
||||
from selling.doctype.sales_order.sales_order import make_delivery_note
|
||||
|
||||
so = webnotes.bean(copy=test_records[0]).insert()
|
||||
|
||||
self.assertRaises(webnotes.ValidationError, make_delivery_note,
|
||||
so.doc.name)
|
||||
|
||||
sales_order = webnotes.bean("Sales Order", so.doc.name)
|
||||
sales_order.submit()
|
||||
dn = make_delivery_note(so.doc.name)
|
||||
|
||||
self.assertEquals(dn[0]["doctype"], "Delivery Note")
|
||||
self.assertEquals(len(dn), len(sales_order.doclist))
|
||||
|
||||
def create_so(self, so_doclist = None):
|
||||
if not so_doclist:
|
||||
so_doclist =test_records[0]
|
||||
|
@ -57,17 +57,10 @@ cur_frm.cscript.customer_address = cur_frm.cscript.contact_person = function(doc
|
||||
|
||||
|
||||
cur_frm.cscript.get_items = function(doc,dt,dn) {
|
||||
var callback = function(r,rt){
|
||||
var doc = locals[cur_frm.doctype][cur_frm.docname];
|
||||
if(r.message){
|
||||
doc.sales_order_no = r.message;
|
||||
if(doc.sales_order_no) {
|
||||
unhide_field(['customer_address','contact_person','territory','customer_group']);
|
||||
}
|
||||
cur_frm.refresh_fields();
|
||||
}
|
||||
}
|
||||
$c_obj(make_doclist(doc.doctype, doc.name),'pull_sales_order_details','',callback);
|
||||
wn.model.map_current_doc({
|
||||
method: "selling.doctype.sales_order.sales_order.make_delivery_note",
|
||||
source_name: cur_frm.doc.sales_order_no,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
|
@ -63,19 +63,6 @@ class DocType(SellingController):
|
||||
"""Get Commission rate of Sales Partner"""
|
||||
return get_obj('Sales Common').get_comm_rate(sales_partner, self)
|
||||
|
||||
|
||||
def pull_sales_order_details(self):
|
||||
self.validate_prev_docname()
|
||||
self.doclist = self.doc.clear_table(self.doclist,'other_charges')
|
||||
|
||||
if self.doc.sales_order_no:
|
||||
get_obj('DocType Mapper', 'Sales Order-Delivery Note').dt_map('Sales Order', 'Delivery Note', self.doc.sales_order_no, self.doc, self.doclist, "[['Sales Order', 'Delivery Note'],['Sales Order Item', 'Delivery Note Item'],['Sales Taxes and Charges','Sales Taxes and Charges'],['Sales Team','Sales Team']]")
|
||||
else:
|
||||
msgprint("Please select Sales Order No. whose details need to be pulled")
|
||||
|
||||
return cstr(self.doc.sales_order_no)
|
||||
|
||||
|
||||
def validate_prev_docname(self):
|
||||
"""Validates that Sales Order is not pulled twice"""
|
||||
for d in getlist(self.doclist, 'delivery_note_details'):
|
||||
|
@ -102,13 +102,19 @@ cur_frm.cscript['Unstop Material Request'] = function(){
|
||||
};
|
||||
|
||||
cur_frm.cscript['Make Purchase Order'] = function() {
|
||||
cur_frm.map([["Material Request", "Purchase Order"], ["Material Request Item", "Purchase Order Item"]]);
|
||||
cur_frm.map([
|
||||
["Material Request", "Purchase Order"],
|
||||
["Material Request Item", "Purchase Order Item"]]);
|
||||
};
|
||||
|
||||
cur_frm.cscript.make_supplier_quotation = function() {
|
||||
cur_frm.map([["Material Request", "Supplier Quotation"], ["Material Request Item", "Supplier Quotation Item"]]);
|
||||
cur_frm.map([
|
||||
["Material Request", "Supplier Quotation"],
|
||||
["Material Request Item", "Supplier Quotation Item"]]);
|
||||
};
|
||||
|
||||
cur_frm.cscript.make_stock_entry = function() {
|
||||
cur_frm.map([["Material Request", "Stock Entry"], ["Material Request Item", "Stock Entry Detail"]]);
|
||||
cur_frm.map([
|
||||
["Material Request", "Stock Entry"],
|
||||
["Material Request Item", "Stock Entry Detail"]]);
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user