code: def action_approve(self):
          
          for rec in self:
              if rec.state not in ['draft', 'to approve']:
                  raise UserError(
                      _("Can't approve page in '%s' state.") % rec.state)
              if not rec.am_i_approver:
                  raise UserError(_(
                      'You are not authorized to do this.\r\n'
                      'Only approvers with these groups can approve this: '
                      ) % ', '.join(
                          [g.display_name
                              for g in rec.page_id.approver_group_ids]))
              # Update state
              rec.write({
                  'state': 'approved',
                  'approved_date': fields.datetime.now(),
                  'approved_uid': self.env.uid,
              })
              # Trigger computed field update
              rec.page_id._compute_history_head()
              # Notify state change
              rec.message_post(
                  subtype='mt_comment',
                  body=_(
                      'Change request has been approved by %s.'
                      ) % (self.env.user.name)
              )
              # Notify followers a new version is available
              rec.page_id.message_post(
                  subtype='mt_comment',
                  body=_(
                      'New version of the document %s approved.'
                      ) % (rec.page_id.name)
              )
docs: Set a change request as approved.