[mapper] quotation-sales order for mapping in parent + child items
This commit is contained in:
parent
8aded138c7
commit
080fcc8fcd
@ -262,7 +262,9 @@ class SellingController(StockController):
|
|||||||
|
|
||||||
def validate_order_type(self):
|
def validate_order_type(self):
|
||||||
valid_types = ["Sales", "Maintenance", "Shopping Cart"]
|
valid_types = ["Sales", "Maintenance", "Shopping Cart"]
|
||||||
if self.doc.order_type not in valid_types:
|
if not self.doc.order_type:
|
||||||
|
self.doc.order_type = "Sales"
|
||||||
|
elif self.doc.order_type not in valid_types:
|
||||||
msgprint(_(self.meta.get_label("order_type")) + " " +
|
msgprint(_(self.meta.get_label("order_type")) + " " +
|
||||||
_("must be one of") + ": " + comma_or(valid_types),
|
_("must be one of") + ": " + comma_or(valid_types),
|
||||||
raise_exception=True)
|
raise_exception=True)
|
||||||
|
@ -113,6 +113,6 @@ def make_customer(source_name, target_doclist=None):
|
|||||||
"contact_no": "phone_1",
|
"contact_no": "phone_1",
|
||||||
"fax": "fax_1"
|
"fax": "fax_1"
|
||||||
}
|
}
|
||||||
}})
|
}}, target_doclist)
|
||||||
|
|
||||||
return [d.fields for d in doclist]
|
return [d.fields for d in doclist]
|
@ -119,20 +119,10 @@ cur_frm.fields_dict['enq_no'].get_query = function(doc,cdt,cdn){
|
|||||||
// Make Sales Order
|
// Make Sales Order
|
||||||
// =====================================================================================
|
// =====================================================================================
|
||||||
cur_frm.cscript['Make Sales Order'] = function() {
|
cur_frm.cscript['Make Sales Order'] = function() {
|
||||||
var doc = cur_frm.doc;
|
wn.model.open_mapped_doc({
|
||||||
|
method: "selling.doctype.quotation.quotation.make_sales_order",
|
||||||
if (doc.docstatus == 1) {
|
source_name: cur_frm.doc.name
|
||||||
var n = wn.model.make_new_doc_and_get_name("Sales Order");
|
})
|
||||||
$c('dt_map', args={
|
|
||||||
'docs':wn.model.compress([locals["Sales Order"][n]]),
|
|
||||||
'from_doctype':'Quotation',
|
|
||||||
'to_doctype':'Sales Order',
|
|
||||||
'from_docname':doc.name,
|
|
||||||
'from_to_list':"[['Quotation', 'Sales Order'], ['Quotation Item', 'Sales Order Item'],['Sales Taxes and Charges','Sales Taxes and Charges'], ['Sales Team', 'Sales Team'], ['TC Detail', 'TC Detail']]"
|
|
||||||
}, function(r,rt) {
|
|
||||||
loaddoc("Sales Order", n);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//pull enquiry details
|
//pull enquiry details
|
||||||
|
@ -250,3 +250,37 @@ class DocType(SellingController):
|
|||||||
sql("delete from `tabCommunication Log` where parent = '%s'"%self.doc.name)
|
sql("delete from `tabCommunication Log` where parent = '%s'"%self.doc.name)
|
||||||
for d in getlist(self.doclist, 'follow_up'):
|
for d in getlist(self.doclist, 'follow_up'):
|
||||||
d.save()
|
d.save()
|
||||||
|
|
||||||
|
@webnotes.whitelist()
|
||||||
|
def make_sales_order(source_name, target_doclist=None):
|
||||||
|
from webnotes.model.mapper import get_mapped_doclist
|
||||||
|
|
||||||
|
if target_doclist:
|
||||||
|
target_doclist = json.loads(target_doclist)
|
||||||
|
|
||||||
|
doclist = get_mapped_doclist("Quotation", source_name, {
|
||||||
|
"Quotation": {
|
||||||
|
"doctype": "Sales Order",
|
||||||
|
"field_map": {
|
||||||
|
"name": "quotation_no",
|
||||||
|
"transaction_date": "quotation_date"
|
||||||
|
},
|
||||||
|
"validation": {
|
||||||
|
"docstatus": ["=", 1]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"Quotation Item": {
|
||||||
|
"doctype": "Sales Order Item",
|
||||||
|
"field_map": {
|
||||||
|
"parent": "prevdoc_docname"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"Sales Taxes and Charges": {
|
||||||
|
"doctype": "Sales Taxes and Charges",
|
||||||
|
},
|
||||||
|
"Sales Team": {
|
||||||
|
"doctype": "Sales Team",
|
||||||
|
}
|
||||||
|
}, target_doclist)
|
||||||
|
|
||||||
|
return [d.fields for d in doclist]
|
@ -1,17 +1,31 @@
|
|||||||
import webnotes
|
import webnotes, json
|
||||||
from webnotes.utils import flt
|
from webnotes.utils import flt
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
test_dependencies = ["Sales BOM"]
|
test_dependencies = ["Sales BOM"]
|
||||||
|
|
||||||
class TestLead(unittest.TestCase):
|
class TestQuotation(unittest.TestCase):
|
||||||
def test_make_sales_order(self):
|
def test_make_sales_order(self):
|
||||||
lead = webnotes.bean("Lead", "_T-Lead-00001")
|
from selling.doctype.quotation.quotation import make_sales_order
|
||||||
lead.make_controller()
|
|
||||||
customer = lead.controller.make_customer()
|
self.assertRaises(webnotes.ValidationError, make_sales_order, "_T-Quotation-00001")
|
||||||
self.assertEquals(customer[0].doctype, "Customer")
|
|
||||||
self.assertEquals(customer[0].lead_name, lead.doc.name)
|
quotation = webnotes.bean("Quotation","_T-Quotation-00001")
|
||||||
webnotes.bean(customer).insert()
|
quotation.submit()
|
||||||
|
|
||||||
|
sales_order = make_sales_order("_T-Quotation-00001")
|
||||||
|
|
||||||
|
self.assertEquals(sales_order[0]["doctype"], "Sales Order")
|
||||||
|
self.assertEquals(len(sales_order), 2)
|
||||||
|
self.assertEquals(sales_order[1]["doctype"], "Sales Order Item")
|
||||||
|
self.assertEquals(sales_order[1]["prevdoc_docname"], "_T-Quotation-00001")
|
||||||
|
self.assertEquals(sales_order[0]["customer"], "_Test Customer")
|
||||||
|
|
||||||
|
sales_order[0]["delivery_date"] = "2014-01-01"
|
||||||
|
|
||||||
|
|
||||||
|
webnotes.print_messages = True
|
||||||
|
webnotes.bean(sales_order).insert()
|
||||||
|
|
||||||
|
|
||||||
test_records = [
|
test_records = [
|
||||||
|
@ -167,7 +167,7 @@ class DocType(SellingController):
|
|||||||
def validate_order_type(self):
|
def validate_order_type(self):
|
||||||
super(DocType, self).validate_order_type()
|
super(DocType, self).validate_order_type()
|
||||||
|
|
||||||
#validate delivery date
|
def validate_delivery_date(self):
|
||||||
if self.doc.order_type == 'Sales' and not self.doc.delivery_date:
|
if self.doc.order_type == 'Sales' and not self.doc.delivery_date:
|
||||||
msgprint("Please enter 'Expected Delivery Date'")
|
msgprint("Please enter 'Expected Delivery Date'")
|
||||||
raise Exception
|
raise Exception
|
||||||
@ -186,6 +186,7 @@ class DocType(SellingController):
|
|||||||
|
|
||||||
self.validate_fiscal_year()
|
self.validate_fiscal_year()
|
||||||
self.validate_order_type()
|
self.validate_order_type()
|
||||||
|
self.validate_delivery_date()
|
||||||
self.validate_mandatory()
|
self.validate_mandatory()
|
||||||
self.validate_proj_cust()
|
self.validate_proj_cust()
|
||||||
self.validate_po()
|
self.validate_po()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user