[fix] recurring patch for purchase

This commit is contained in:
Rushabh Mehta 2016-03-22 11:01:31 +05:30
parent 97e523b4a4
commit 79a6fc9a84

View File

@ -11,14 +11,16 @@ def execute():
"stock_doctype": "Delivery Note",
"invoice_doctype": "Sales Invoice",
"stock_doctype_ref_field": "against_sales_order",
"invoice_ref_field": "sales_order"
"invoice_ref_field": "sales_order",
"qty_field": "delivered_qty"
},
{
"doctype": "Purchase Order",
"stock_doctype": "Purchase Receipt",
"invoice_doctype": "Purchase Invoice",
"stock_doctype_ref_field": "prevdoc_docname",
"invoice_ref_field": "purchase_order"
"invoice_ref_field": "purchase_order",
"qty_field": "received_qty"
}):
order_list = frappe.db.sql("""select name from `tab{0}`
@ -28,7 +30,8 @@ def execute():
for order in order_list:
frappe.db.sql("""update `tab{0} Item`
set delivered_qty=0, billed_amt=0 where parent=%s""".format(doc["doctype"]), order.name)
set {1}=0, billed_amt=0 where parent=%s""".format(doc["doctype"],
doc["qty_field"]), order.name)
# Check against Delivery Note and Purchase Receipt
stock_doc_list = frappe.db.sql("""select distinct parent from `tab{0} Item`