<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def revert(self):
 """Revert the document to currently published version"""


        with self.draft_context():
            draft = self.one(Q._uid == self._uid)

        with self.published_context():
            published = self.one(Q._uid == self._uid)

        for field, value in draft._document.items():
            if field in self._unpublished_fields:
                continue
            setattr(draft, field, getattr(published, field))

        # Revert the revision
        draft.revision = published.revision

        draft.update()