Changed model extension to save attachment after save

It raise an error to try to save attachment to a unsaved model. And it
doesn’t make sense to save attachment before we are sure that the model
is saved correctly.
Merge pull request #1 from nicdal/master

Changed model extension to save attachment after save