[fix] status update - update qty after int float not null change
This commit is contained in:
parent
625592e997
commit
ebae726237
@ -177,6 +177,7 @@ class StatusUpdater(Document):
|
||||
else:
|
||||
args['cond'] = ' and parent!="%s"' % self.name.replace('"', '\"')
|
||||
|
||||
args['set_modified'] = ''
|
||||
if change_modified:
|
||||
args['set_modified'] = ', modified = now(), modified_by = "{0}"'\
|
||||
.format(frappe.db.escape(frappe.session.user))
|
||||
@ -210,7 +211,7 @@ class StatusUpdater(Document):
|
||||
if not args.get("extra_cond"): args["extra_cond"] = ""
|
||||
|
||||
frappe.db.sql("""update `tab%(target_dt)s`
|
||||
set %(target_field)s = (select sum(%(source_field)s)
|
||||
set %(target_field)s = (select ifnull(sum(%(source_field)s), 0)
|
||||
from `tab%(source_dt)s` where `%(join_field)s`="%(detail_id)s"
|
||||
and (docstatus=1 %(cond)s) %(extra_cond)s) %(second_source_condition)s
|
||||
where name='%(detail_id)s'""" % args)
|
||||
@ -228,10 +229,12 @@ class StatusUpdater(Document):
|
||||
# update percent complete in the parent table
|
||||
if args.get('target_parent_field'):
|
||||
frappe.db.sql("""update `tab%(target_parent_dt)s`
|
||||
set %(target_parent_field)s = round((select sum(if(%(target_ref_field)s >
|
||||
%(target_field)s, %(target_field)s,
|
||||
%(target_ref_field)s))/sum(%(target_ref_field)s)*100
|
||||
from `tab%(target_dt)s` where parent="%(name)s"), 2) %(set_modified)s
|
||||
set %(target_parent_field)s = round(
|
||||
ifnull((select
|
||||
ifnull(sum(if(%(target_ref_field)s > %(target_field)s, %(target_field)s, %(target_ref_field)s)), 0)
|
||||
/ sum(%(target_ref_field)s) * 100
|
||||
from `tab%(target_dt)s` where parent="%(name)s"), 0), 2)
|
||||
%(set_modified)s
|
||||
where name='%(name)s'""" % args)
|
||||
|
||||
# update field
|
||||
@ -264,10 +267,10 @@ class StatusUpdater(Document):
|
||||
|
||||
def update_billing_status(self, zero_amount_refdoc, ref_dt, ref_fieldname):
|
||||
for ref_dn in zero_amount_refdoc:
|
||||
ref_doc_qty = flt(frappe.db.sql("""select sum(qty) from `tab%s Item`
|
||||
ref_doc_qty = flt(frappe.db.sql("""select ifnull(sum(qty), 0) from `tab%s Item`
|
||||
where parent=%s""" % (ref_dt, '%s'), (ref_dn))[0][0])
|
||||
|
||||
billed_qty = flt(frappe.db.sql("""select sum(qty)
|
||||
billed_qty = flt(frappe.db.sql("""select ifnull(sum(qty), 0)
|
||||
from `tab%s Item` where %s=%s and docstatus=1""" %
|
||||
(self.doctype, ref_fieldname, '%s'), (ref_dn))[0][0])
|
||||
|
||||
|
@ -234,3 +234,4 @@ erpnext.patches.v6_6.remove_fiscal_year_from_leave_allocation
|
||||
execute:frappe.delete_doc_if_exists("DocType", "Stock UOM Replace Utility")
|
||||
erpnext.patches.v6_8.make_webform_standard #2015-11-23
|
||||
erpnext.patches.v6_8.move_drop_ship_to_po_items
|
||||
erpnext.patches.v6_10.fix_ordered_received_billed
|
||||
|
1
erpnext/patches/v6_10/__init__.py
Normal file
1
erpnext/patches/v6_10/__init__.py
Normal file
@ -0,0 +1 @@
|
||||
from __future__ import unicode_literals
|
17
erpnext/patches/v6_10/fix_ordered_received_billed.py
Normal file
17
erpnext/patches/v6_10/fix_ordered_received_billed.py
Normal file
@ -0,0 +1,17 @@
|
||||
from __future__ import unicode_literals
|
||||
import frappe
|
||||
|
||||
def execute():
|
||||
not_null_patch_date = frappe.db.sql("""select date(creation) from `tabPatch Log` where patch='frappe.patches.v6_9.int_float_not_null'""")
|
||||
if not not_null_patch_date:
|
||||
return
|
||||
|
||||
not_null_patch_date = not_null_patch_date[0][0]
|
||||
|
||||
for doctype in ("Purchase Invoice", "Sales Invoice", "Purchase Order", "Delivery Note", "Installation Note", "Delivery Note", "Purchase Receipt"):
|
||||
for name in frappe.db.sql_list("""select name from `tab{doctype}`
|
||||
where docstatus > 0 and (date(creation) >= %(patch_date)s or date(modified) >= %(patch_date)s)""".format(doctype=doctype),
|
||||
{"patch_date": not_null_patch_date}):
|
||||
|
||||
doc = frappe.get_doc(doctype, name)
|
||||
doc.update_qty(change_modified=False)
|
Loading…
x
Reference in New Issue
Block a user