'Update percent field in parent transaction'

def _update_percent_field(self, args, update_modified=True):

    self._update_modified(args, update_modified)
    if args.get(u'target_parent_field'):
        frappe.db.sql((u'update    `tab%(target_parent_dt)s`\n DCTB  DCTB  DCTB  DCTB set    %(target_parent_field)s    =    round(\n DCTB  DCTB  DCTB  DCTB  DCTB ifnull((select\n DCTB  DCTB  DCTB  DCTB  DCTB  DCTB ifnull(sum(if(%(target_ref_field)s    >    %(target_field)s,    abs(%(target_field)s),    abs(%(target_ref_field)s))),    0)\n DCTB  DCTB  DCTB  DCTB  DCTB  DCTB /    sum(abs(%(target_ref_field)s))    *    100\n DCTB  DCTB  DCTB  DCTB  DCTB from    `tab%(target_dt)s`    where    parent="%(name)s"),    0),    2)\n DCTB  DCTB  DCTB  DCTB  DCTB %(update_modified)s\n DCTB  DCTB  DCTB  DCTB where    name=\'%(name)s\'' % args))
        if args.get(u'status_field'):
            frappe.db.sql((u"update    `tab%(target_parent_dt)s`\n DCTB  DCTB  DCTB  DCTB  DCTB set    %(status_field)s    =    if(%(target_parent_field)s<0.001,\n DCTB  DCTB  DCTB  DCTB  DCTB  DCTB 'Not    %(keyword)s',    if(%(target_parent_field)s>=99.99,\n DCTB  DCTB  DCTB  DCTB  DCTB  DCTB 'Fully    %(keyword)s',    'Partly    %(keyword)s'))\n DCTB  DCTB  DCTB  DCTB  DCTB where    name='%(name)s'" % args))
        if update_modified:
            target = frappe.get_doc(args[u'target_parent_dt'], args[u'name'])
            target.set_status(update=True)
            target.notify_update()
