The Switch
(2010)

Wally (Jason Bateman) and Kassie (Jennifer Aniston) are friends.  Kassie decides to use a sperm donor to become pregnant.  Wally gets very upset and tries to change her mind, but Kassie is tired of waiting and is ready right now.  At her Insemination Party, Wally gets very, very drunk and, in the bathroom, accidentally knocks Roland the Sperm Donor's (Patrick Wilson) cup into the sink.  Wally has to replenish the supply himself.  He gets to his friend, Leonard's (Jeff Goldblum), house at 3 a.m., but cannot remember what he has done.

After telling Wally that she's pregnant, Kassie tells him that she is moving home to be near her family.  Eventually, they lose touch and years pass.

About 7 years after leaving New York, Kassie gets a great job and moves back with her son, Sebastian (Thomas Robinson).  They go to dinner with Wally and it turns out that Wally and Sebastian share a lot of the same traits.  Sebastian collects new photo frames with the pictures that come with the frame in them (later we find out that it's so he can pretend that they're his family).  Kassie and Roland get back in touch with each other and begin dating and becoming serious, even though Sebastian (and Wally) doesn't like Roland.  Wally and Leonard start talking about the night of the insemination party and eventually remember what Wally did.  Leonard tells Wally that he has to tell Kassie, but Wally misses his chance.  He realizes that he's in love with Kassie.  After trying (and failing) to tell Kassie a couple of times, Wally finally gets his chance at  formal brunch that Kassie is having for Roland's family.  When Roland stands up to propose, Wally tells Kassie what happened...in front of Roland and his family.  Kassie walks out of the room and Wally follows.  She slaps him and tells him that he'll never see either her or Sebastian again.

Some time later, Wally comes out of his work to see Kassie waiting for him.  She tells him that she isn't going to marry Roland after all ("because he isn't you") and that he can see Sebastian after all.  He asks her to marry him and she says "probably".

Later, we see Sebastian's 7th birthday party.  The picture frames all have pictures of Sebastian and Kassie and Wally in them.

Thanks Rowan!