def METHOD_NAME(self):
    active_id = self.env.context.get("active_id") or False
    if not active_id:
        raise UserError(_("No active ID found."))
    self.env["riba.distinta"].browse(active_id).state = "accredited"
    return {"type": "ir.actions.act_window_close"}