[minor] sales invoice to delivery note mapping and prevdoc validation
This commit is contained in:
parent
354d0bdca8
commit
90d74d4bfa
@ -60,7 +60,7 @@ erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.exte
|
|||||||
|
|
||||||
cur_frm.add_custom_button('Send SMS', cur_frm.cscript.send_sms);
|
cur_frm.add_custom_button('Send SMS', cur_frm.cscript.send_sms);
|
||||||
|
|
||||||
if(doc.is_pos==1 && doc.update_stock!=1)
|
if(cint(doc.update_stock)!=1)
|
||||||
cur_frm.add_custom_button('Make Delivery', cur_frm.cscript['Make Delivery Note']);
|
cur_frm.add_custom_button('Make Delivery', cur_frm.cscript['Make Delivery Note']);
|
||||||
|
|
||||||
if(doc.outstanding_amount!=0)
|
if(doc.outstanding_amount!=0)
|
||||||
|
@ -983,3 +983,49 @@ def get_income_account(doctype, txt, searchfield, start, page_len, filters):
|
|||||||
and tabAccount.%(key)s LIKE '%(txt)s'
|
and tabAccount.%(key)s LIKE '%(txt)s'
|
||||||
%(mcond)s""" % {'company': filters['company'], 'key': searchfield,
|
%(mcond)s""" % {'company': filters['company'], 'key': searchfield,
|
||||||
'txt': "%%%s%%" % txt, 'mcond':get_match_cond(doctype, searchfield)})
|
'txt': "%%%s%%" % txt, 'mcond':get_match_cond(doctype, searchfield)})
|
||||||
|
|
||||||
|
|
||||||
|
@webnotes.whitelist()
|
||||||
|
def make_delivery_note(source_name, target_doclist=None):
|
||||||
|
from webnotes.model.mapper import get_mapped_doclist
|
||||||
|
|
||||||
|
def set_missing_values(source, target):
|
||||||
|
bean = webnotes.bean(target)
|
||||||
|
bean.run_method("onload_post_render")
|
||||||
|
|
||||||
|
def update_item(obj, target, source_parent):
|
||||||
|
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 Invoice", source_name, {
|
||||||
|
"Sales Invoice": {
|
||||||
|
"doctype": "Delivery Note",
|
||||||
|
"validation": {
|
||||||
|
"docstatus": ["=", 1]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"Sales Invoice Item": {
|
||||||
|
"doctype": "Delivery Note Item",
|
||||||
|
"field_map": {
|
||||||
|
"name": "prevdoc_detail_docname",
|
||||||
|
"parent": "prevdoc_docname",
|
||||||
|
"parenttype": "prevdoc_doctype",
|
||||||
|
"serial_no": "serial_no"
|
||||||
|
},
|
||||||
|
"postprocess": update_item
|
||||||
|
},
|
||||||
|
"Sales Taxes and Charges": {
|
||||||
|
"doctype": "Sales Taxes and Charges",
|
||||||
|
"add_if_empty": True
|
||||||
|
},
|
||||||
|
"Sales Team": {
|
||||||
|
"doctype": "Sales Team",
|
||||||
|
"field_map": {
|
||||||
|
"incentives": "incentives"
|
||||||
|
},
|
||||||
|
"add_if_empty": True
|
||||||
|
}
|
||||||
|
}, target_doclist, set_missing_values)
|
||||||
|
|
||||||
|
return [d.fields for d in doclist]
|
@ -262,4 +262,5 @@ patch_list = [
|
|||||||
"patches.july_2013.p08_custom_print_format_net_total_export",
|
"patches.july_2013.p08_custom_print_format_net_total_export",
|
||||||
"patches.july_2013.p09_remove_website_pyc",
|
"patches.july_2013.p09_remove_website_pyc",
|
||||||
"patches.july_2013.p10_change_partner_user_to_website_user",
|
"patches.july_2013.p10_change_partner_user_to_website_user",
|
||||||
|
"execute:webnotes.bean('Selling Settings').save()",
|
||||||
]
|
]
|
@ -8,5 +8,5 @@ class DocType:
|
|||||||
self.doc, self.doclist = d, dl
|
self.doc, self.doclist = d, dl
|
||||||
|
|
||||||
def validate(self):
|
def validate(self):
|
||||||
for key in ["cust_master_name", "customer_group", "territory", "allow_same_sales_rate"]:
|
for key in ["cust_master_name", "customer_group", "territory", "maintain_same_sales_rate"]:
|
||||||
webnotes.conn.set_default(key, self.doc.fields.get(key, ""))
|
webnotes.conn.set_default(key, self.doc.fields.get(key, ""))
|
||||||
|
@ -113,21 +113,24 @@ class DocType(SellingController):
|
|||||||
if not self.doc.installation_status: self.doc.installation_status = 'Not Installed'
|
if not self.doc.installation_status: self.doc.installation_status = 'Not Installed'
|
||||||
|
|
||||||
def validate_with_previous_doc(self):
|
def validate_with_previous_doc(self):
|
||||||
super(DocType, self).validate_with_previous_doc(self.tname, {
|
prev_doctype = [d.prevdoc_doctype for d in self.doclist.get({
|
||||||
"Sales Order": {
|
"parentfield": "delivery_note_details", "prevdoc_doctype": ["!=", ""]})]
|
||||||
"ref_dn_field": "prevdoc_docname",
|
if prev_doctype:
|
||||||
"compare_fields": [["customer", "="], ["company", "="], ["project_name", "="],
|
|
||||||
["currency", "="]],
|
|
||||||
},
|
|
||||||
})
|
|
||||||
if cint(webnotes.defaults.get_global_default('maintain_same_sales_rate')):
|
|
||||||
super(DocType, self).validate_with_previous_doc(self.tname, {
|
super(DocType, self).validate_with_previous_doc(self.tname, {
|
||||||
"Sales Order Item": {
|
prev_doctype[0]: {
|
||||||
"ref_dn_field": "prevdoc_detail_docname",
|
"ref_dn_field": "prevdoc_docname",
|
||||||
"compare_fields": [["export_rate", "="]],
|
"compare_fields": [["customer", "="], ["company", "="], ["project_name", "="],
|
||||||
"is_child_table": True
|
["currency", "="]],
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
|
if cint(webnotes.defaults.get_global_default('maintain_same_sales_rate')):
|
||||||
|
super(DocType, self).validate_with_previous_doc(self.tname, {
|
||||||
|
prev_doctype[0] + " Item": {
|
||||||
|
"ref_dn_field": "prevdoc_detail_docname",
|
||||||
|
"compare_fields": [["export_rate", "="]],
|
||||||
|
"is_child_table": True
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
def validate_proj_cust(self):
|
def validate_proj_cust(self):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user