
from __future__ import unicode_literals
import frappe

def execute():
	frappe.db.sql("""update `tabSales Order` set delivery_status = 'Not Delivered' 
		where delivery_status = 'Delivered' and ifnull(per_delivered, 0) = 0""")

	frappe.db.sql("""update `tabSales Order` set billing_status = 'Not Billed' 
		where billing_status = 'Billed' and ifnull(per_billed, 0) = 0""")

from __future__ import unicode_literals
import frappe

def execute():
	frappe.db.sql("""update `tabSales Order` set delivery_status = 'Not Delivered' 
		where delivery_status = 'Delivered' and ifnull(per_delivered, 0) = 0 and docstatus = 0""")

	frappe.db.sql("""update `tabSales Order` set billing_status = 'Not Billed' 
		where billing_status = 'Billed' and ifnull(per_billed, 0) = 0 and docstatus = 0""")
Update delivery and billing status in SO
Update delivery and billing status in SO

  
  from __future__ import unicode_literals
  import frappe
  
  def execute():
  	frappe.db.sql("""update `tabSales Order` set delivery_status = 'Not Delivered' 
- 		where delivery_status = 'Delivered' and ifnull(per_delivered, 0) = 0""")
+ 		where delivery_status = 'Delivered' and ifnull(per_delivered, 0) = 0 and docstatus = 0""")
  
  	frappe.db.sql("""update `tabSales Order` set billing_status = 'Not Billed' 
- 		where billing_status = 'Billed' and ifnull(per_billed, 0) = 0""")
+ 		where billing_status = 'Billed' and ifnull(per_billed, 0) = 0 and docstatus = 0""")
Update delivery and billing status in SO
## Code Before:

from __future__ import unicode_literals
import frappe

def execute():
	frappe.db.sql("""update `tabSales Order` set delivery_status = 'Not Delivered' 
		where delivery_status = 'Delivered' and ifnull(per_delivered, 0) = 0""")

	frappe.db.sql("""update `tabSales Order` set billing_status = 'Not Billed' 
		where billing_status = 'Billed' and ifnull(per_billed, 0) = 0""")
## Instruction:
Update delivery and billing status in SO
## Code After:

from __future__ import unicode_literals
import frappe

def execute():
	frappe.db.sql("""update `tabSales Order` set delivery_status = 'Not Delivered' 
		where delivery_status = 'Delivered' and ifnull(per_delivered, 0) = 0 and docstatus = 0""")

	frappe.db.sql("""update `tabSales Order` set billing_status = 'Not Billed' 
		where billing_status = 'Billed' and ifnull(per_billed, 0) = 0 and docstatus = 0""")