Reset no-copy fields for recurring docs and patch to fix

This commit is contained in:
Nabin Hait 2015-04-16 13:13:18 +05:30
parent 68dfc934bf
commit c3daa91c8a
4 changed files with 65 additions and 1 deletions

View File

@ -198,6 +198,17 @@ class PurchaseOrder(BuyingController):
def on_update(self):
pass
def before_recurring(self):
super(PurchaseOrder, self).before_recurring()
for field in ("per_received", "per_billed"):
self.set(field, None)
for d in self.get("po_details"):
for field in ("received_qty", "billed_amt", "prevdoc_doctype", "prevdoc_docname",
"prevdoc_detail_docname", "supplier_quotation", "supplier_quotation_item"):
d.set(field, None)
def set_missing_values(source, target):
target.ignore_pricing_rule = 1
target.run_method("set_missing_values")

View File

@ -96,3 +96,4 @@ erpnext.patches.v4_2.set_item_has_batch
erpnext.patches.v4_2.update_stock_uom_for_dn_in_sle
erpnext.patches.v4_2.repost_reserved_qty
erpnext.patches.v4_2.repost_sle_for_si_with_no_warehouse
erpnext.patches.v4_2.fix_recurring_orders

View File

@ -0,0 +1,41 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import frappe
def execute():
sales_orders = frappe.db.sql("""select name from `tabSales Order`
where docstatus = 1 and ifnull(is_recurring, 0) = 1
and (per_delivered > 0 or per_billed > 0)""", as_dict=1)
for so in sales_orders:
if not frappe.db.exists("Delivery Note Item", {"against_sales_order": so.name, "docstatus": 1}):
frappe.db.sql("""update `tabSales Order` set per_delivered = 0,
delivery_status = 'Not Delivered' where name = %s""", so.name)
frappe.db.sql("""update `tabSales Order Item` set delivered_qty = 0
where parent = %s""", so.name)
if not frappe.db.exists("Sales Invoice Item", {"sales_order": so.name, "docstatus": 1}):
frappe.db.sql("""update `tabSales Order` set per_billed = 0,
billing_status = 'Not Billed' where name = %s""", so.name)
frappe.db.sql("""update `tabSales Order Item` set billed_amt = 0
where parent = %s""", so.name)
purchase_orders = frappe.db.sql("""select name from `tabPurchase Order`
where docstatus = 1 and ifnull(is_recurring, 0) = 1
and (per_received > 0 or per_billed > 0)""", as_dict=1)
for po in purchase_orders:
if not frappe.db.exists("Purchase Receipt Item", {"prevdoc_doctype": "Purchase Order",
"prevdoc_docname": po.name, "docstatus": 1}):
frappe.db.sql("""update `tabPurchase Order` set per_received = 0
where name = %s""", po.name)
frappe.db.sql("""update `tabPurchase Order Item` set received_qty = 0
where parent = %s""", po.name)
if not frappe.db.exists("Purchase Invoice Item", {"purchase_order": po.name, "docstatus": 1}):
frappe.db.sql("""update `tabPurchase Order` set per_billed = 0
where name = %s""", po.name)
frappe.db.sql("""update `tabPurchase Order Item` set billed_amt = 0
where parent = %s""", po.name)

View File

@ -249,6 +249,17 @@ class SalesOrder(SellingController):
def get_portal_page(self):
return "order" if self.docstatus==1 else None
def before_recurring(self):
super(SalesOrder, self).before_recurring()
for field in ("delivery_status", "per_delivered", "billing_status", "per_billed"):
self.set(field, None)
for d in self.get("sales_order_details"):
for field in ("delivered_qty", "billed_amt", "planned_qty", "prevdoc_docname"):
d.set(field, None)
@frappe.whitelist()
def make_material_request(source_name, target_doc=None):
def postprocess(source, doc):