I think the 7 year old can and should attend. By age 7, most children have concrete, fact-based thinking, and are not affected much by magical thinking of earlier ages.
Also, there is comfort for other attendees in seeing children. It reminds us all that we have to die to make room for the next generation. And the presence of such children are usually a comfort to adults, regardless of their behavior, unless it is overwhelming.
When DS was 8 years old, I had arranged a visit with just me and him at my parents' house (flying from PA to CA). A month before the scheduled and booked visit, Mom showed signs of insanity-delusions, and other crazy stuff. Everyone knew there was something very wrong from the emails she was sending to family, and from talking to my dad. My dad and I were able to figure out that she was abusing steroids that had been prescribed for an inflammatory condition. She had been ordering refills at both the local pharmacy and mail order through Kaiser, and she had kept herself on high doses. So I suspected steroid psychosis.
I had some plans for some fun escapes with DS, which became vital during our visit. I stuck with bringing him on the visit, as it would be a comfort to Dad. I explained to him there was something wrong with Grandma and we were there to help figure it out, get her the help she needed, and help support Grandpa. DS was a total champ. He saw Grandma act crazy, saw her deterioration over the previous year.
I actually wanted not to shelter him from real life. I explained that sometimes that happens when people have medical problems, and that it was OK. It is better to deal with reality than run away. A month or two later we found that her psychosis was not just steroid psychosis, but also due to an undiagnosed small cell lung cancer.
My goal was to get her to the doctor so she could see what was going on with mom, which through crazy manipulation, happened. DS was there by my side. We got her to her doctor, who sent her to the ER, which then arranged a psychiatric hospitalization, where they treated her with anti-psychotics and weaned her steroids.
Once she was situated, DS and I visited an Marriott's Great America in Santa Clara and a water park in Concord. There we had the time of our lives. My dad appreciated the support but was happy also for his alone time when we went out.
DS learned that minds and bodies can both fail. He also learned that one can seek some enjoyment even in sad and difficult times.
Looking back, I suspect that trip had a huge positive impact on his attitudes, even today.
So yes, have the 7 year old attend the funeral.