'Validate that if packed qty exists, it should be equal to qty'

def validate_packed_qty(self):

    if (not any([flt(d.get(u'packed_qty')) for d in self.get(u'items')])):
        return
    has_error = False
    for d in self.get(u'items'):
        if (flt(d.get(u'qty')) != flt(d.get(u'packed_qty'))):
            frappe.msgprint(_(u'Packed    quantity    must    equal    quantity    for    Item    {0}    in    row    {1}').format(d.item_code, d.idx))
            has_error = True
    if has_error:
        raise frappe.ValidationError
