[fix] status updater percent when qty is minus value

This commit is contained in:
RobertSchouten 2016-09-12 14:54:46 +08:00 committed by GitHub
parent b835fef8ac
commit db33ebb0ff

View File

@ -245,8 +245,8 @@ class StatusUpdater(Document):
frappe.db.sql("""update `tab%(target_parent_dt)s` frappe.db.sql("""update `tab%(target_parent_dt)s`
set %(target_parent_field)s = round( set %(target_parent_field)s = round(
ifnull((select ifnull((select
ifnull(sum(if(%(target_ref_field)s > %(target_field)s, %(target_field)s, %(target_ref_field)s)), 0) ifnull(sum(if(%(target_ref_field)s > %(target_field)s, abs(%(target_field)s), abs(%(target_ref_field)s))), 0)
/ sum(%(target_ref_field)s) * 100 / sum(abs(%(target_ref_field)s)) * 100
from `tab%(target_dt)s` where parent="%(name)s"), 0), 2) from `tab%(target_dt)s` where parent="%(name)s"), 0), 2)
%(update_modified)s %(update_modified)s
where name='%(name)s'""" % args) where name='%(name)s'""" % args)